When learning Ruby, one thing always bugged me is the location where class methods are stored. Remember class methods are very similar to the “static” methods in Java anc C++ etc. Once defined, you can use this with the class. I knew that object methods are stored in its class object methods_table and there is no space for class methods as I researched through some of the core data structures MRI uses.

Where are these methods stored then?

Let me tell (guess?) you the answer without further ado.

The class method are stored in the bubblewrap class (aka metaclass) that surrounds the class object. Viola, the problem is solved by not complicating the object structure.

Please correct me if this is wrong.

Advertisement