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

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -