Getter setter questions

Hej all !

I’m sure it’s a basic question but I’ve always been weak on getter setters, can anyone tell me why this doesn’t work please ?

Thanks in advance

Maybe this is a better example : Try Haxe !

Every time you access data, you overwrite the sdata on each access, so if you add stuff to the messages, it will be a different thing. Therefore, trace( data == data ); will always return false :wink: Also, not sure if you realize, but on every access on data you keep parsing the data, which can be pretty heavy.

I would change the api to something like this, where you can access sdata on request:

Thanks Mark for your answer.
Yes I knew that I always parse all stuff, it does’nt matter for the example, it was just to understand the stuff.
But I thought that accessing messages all the parents were parsed again and it seems not be the case, here is my misunderstanding I think right ?

I’ll write traces into getter setters so I’ll see what happen

Ok now I see, you’re right, there is no “set_data” anymore on traces : Try Haxe !