Why MyClass.class.superclass in Ruby is Module -
i had class named myclass in ruby. when check in irb
>class myclass >end > myclass.class.superclass i get
=> module i need know technical description of output
first, lets @ code:
myclass.class #=> class funky. class, instance of class named class. meaning these 2 lines pretty similar:
class myclass; end myclass = class.new and these similar, too.
class myclass; end; myinstance = myclass.new myinstance = class.new.new # know looks funky, works so to:
myclass.class.superclass #=> module so class named class inherits module. makes sense since class behaves module except can instantiate it, , cannot included.
checkout docs class , module more info , how 2 classes work.
realizing ruby "turtles way down" important. , class object being instance of class class 1 of best examples of that, if can head around :)
Comments
Post a Comment