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

python 3.x - Mapping specific letters onto a list of words -

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -