Class

From RubySpec

Jump to: navigation, search

Classes in Ruby are objects just like any other object. They are instances of class "Class". Whenever a new class is created, an object of type Class is created and assigned to a global constant.(Programming Ruby, 1st edition). Classes inherit from Module and Module inherits from Object, which is the topmost class. This can be seen by the sample irb session:

 irb(main):001:0> Class.superclass
 => Module
 irb(main):002:0> Module.superclass
 => Object
 irb(main):003:0> Object.superclass
 => nil
Personal tools