ruby - Class's superclass and String's superclass -


class has superclass module, class, string, has superclass object. why it?

to clear, need check out object model of ruby :

classes, modules, , objects interrelated. in diagram follows, vertical arrows represent inheritance, , parentheses meta-classes. metaclasses instances of class class.

                         +---------+             +-...                          |         |             |          basicobject-----|-->(basicobject)-------|-...              ^           |         ^             |              |           |         |             |           object---------|----->(object)---------|-...              ^           |         ^             |              |           |         |             |              +-------+   |         +--------+    |              |       |   |         |        |    |              |    module-|---------|--->(module)-|-...              |       ^   |         |        ^    |              |       |   |         |        |    |              |     class-|---------|---->(class)-|-...              |       ^   |         |        ^    |              |       +---+         |        +----+              |                     | obj--->otherclass---------->(otherclass)-----------... 

all questions can answered looking @ diagram above.

but class, "string", superclass "object". why it?

look otherclass in diagram. hash, string, array etc otherclass.

in ruby, "class" has superclass "module"

that's how designed, again can answered diagram.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -