What comes first in Ruby's object model?

Posted by Timothy on Stack Overflow See other posts from Stack Overflow or by Timothy
Published on 2010-05-18T18:32:09Z Indexed on 2010/05/18 18:40 UTC
Read the original article Hit count: 247

Filed under:

I've been reading Metaprogramming Ruby and the object model like the chicken or egg dilemma.

In Ruby 1.8, the Object class is an instance of Class. Module's superclass is Object and is an instance of Class. Class' superclass is Module, and it is an instance of Class (self-referential). Say class SomeClass; end is defined somewhere; SomeClass is an instance of Class, however its superclass is Object. Why does an instance of Class have Object as the superclass instead of nil?

Also, if Object is to exist, then Class has to exist, but then Module has to exist, but for Module to exist Object has to exist. How are these classes created?

© Stack Overflow or respective owner

Related posts about ruby