JJB Blog

Ruby class, Class, and Module

irb(main):030:0> Class.class
=> Class
irb(main):031:0> Class.superclass
=> Module
irb(main):032:0> Module.class
=> Class
irb(main):033:0> Module.superclass
=> Object
irb(main):034:0> Object.class
=> Class
irb(main):035:0> Object.superclass
=> nil

So, should this (in particular the parts in bold) blow my mind, or is it just a standard Chicken-Egg situation that exists within the fundamental constructs of any programming language?

I know that for the most part I’ll never have to worry about what’s going on here, but I’d like to explain it to myself once before I forget about it.

UPDATE: okay, ri Class informs me that there is such a thing as a “meta-class”. Knowing that this exists and that I’m not going crazy satisfies me for now. In the future I may read up on the concept further, starting with this article.


2 Comments

Check out http://rhg.rubyforge.org/chapter04.html It’s proven invaluable in my understanding of the Ruby class hierarchy

Posted by Matt on 9 December 2007 @ 5pm

Great, thanks Matt. I didn’t know about the Ruby Hacking Guide.

Posted by John on 9 December 2007 @ 6pm

Leave a Comment