--001636c597163c5795046ee5b6f8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable > So is Class an instance of itself? I don understand the logic behind > this :( Well then you'll love this: Class.class #=> Class Class.superclass #=> Module Class.superclass.superclass #=> Object Module.class #=> Class Object.class #=> Class Object.ancestors #=> [Object, Kernel] Kernel.class #=> Module So Object and Module are instances of a subclass of themselves, and Object inherits from Kernel, which is a Module, a subclass of Object. Fun! The way this actually works is that a Ruby interpreter will implement Object using low-level building blocks, then implement Module and Class on top of that, then perform a bunch of voodoo to make Object and Module *look* like first-class Class instances. Some quick rules on Ruby's type system that I find helpful: * Object is the base type. Everything is an Object. * Module is a type of Object that stores Methods. A module contains a list of methods, and possibly pointers to one or more 'parent' modules mixed in using `include`. * Class is a type of Module that not only stores Methods but can also spawn new Objects that have the class's methods. Additionally, classes have extra inheritance semantics in that subclassing is more restrictive than mixins, and class methods are inherited when subclassing. * Kernel is an *instance* of Module that stores the core methods common to all Objects. It is mixed into Object after Module is created, thereby adding the core methods to all extant objects in the Ruby runtime. -- James Coglan http://jcoglan.com --001636c597163c5795046ee5b6f8--