Method without class instance

Hi everyone.

I’m wondering if anyone can either let me know how to do what I’m trying to do, or suggest an alternative?

Let’s set up a simple example of 3 blocks:

Block 1. Creates a class instance
Block 2. Gets a class variable
Block 3. Sets a class variable

Is there a way for someone to drag Block 2 or 3 out and have it recognize that it’s class has not been initialized, call class initializer itself, and pass its handle to the instance back to the “this” instance that blockly fetches?

In my example above, I used blockly to set my default class instance object name as “classTest”

//% this.defl=“classTest”

I’d love to be able to do a check within a method such as:

let handle = createInstance()
this = handle

And that would assign my default class instance “classTest” so that I would not get a null error.
I don’t know if that would have to happen at the blockly level or some other way.

Any help would be appreciated.


1 Like