I understand that every class in ruby is an instance of class "Class". Even for Object, Kernel class.
However, I can not wrapper my head around how come Object class, which is an ancestor of class Class, can be an instance of class Class, which is it's subclass.
irb(main):018:0* Class.ancestors
=> [Class, Module, Object, Kernel, BasicObject]
irb(main):019:0> Object.ancestors
=> [Object, Kernel, BasicObject]
irb(main):020:0> Object.class
=> Class
ancestors
method comes underModule
and it giveslist of modules included in that module
. So,Class
includesClass, Module, Object, Kernel, BasicObject
modules. And its not like subclass( not extends another class). Reference.