Instance variables for hidden classes?

r = Rect.new(0, 0, 100, 100)puts r.instance_variablesThis prints an empty array, but if you access the methods
Code:
xywidthheight
They return the appropriate values.How is the data stored?

Where is it stored?

Why can't I see it?
Instance variables are simply not used here. Not even hidden ones (name doesn't start with @, so they're inaccessible in Ruby, but not in C++). They are directly stored in dynamically allocated memory (a C++ POD struct in this case). The getter methods simply read the integer from the memory, convert it to a Fix- or Bignum, and return the converted value.

If you want to know the details, you can lookup native extensions, Data (replaced by TypedData in newer Ruby versions) and T_DATA by reading README.EXT, which comes with the Ruby source, or this PDF (jukebox example), etc.

Original thread: https://forums.rpgmakerweb.com/threads/instance-variables-for-hidden-classes.32525/