Motoko, cannot access "this" anymore

I swear I was able to access this in the actor body before. Now I’m getting a

cannot use this before this has been defined

Min reproduction : Motoko Playground - DFINITY

You can use this inside a method, but not in the initialisation expression of an actor’s state variable – at that point, the actor itself is not yet defined (same as with objects). It always was like that.

I’m afraid you’ll have to initialise the variable from within a method somehow.


Dang, makes sense. Thank you for your help :slight_smile:!