Deep Dive into Ruby Class Hierarchy

Ruby treats classes differently. Classes are first-class citizens.

What does that mean? The identifier can be passed around like a normal variable.

Example:

In Ruby, every identifier is an object.So an assignment statement involving two identifiers amounts to passing the reference or pointer or memory address. New values or objects are not created.

The above piece of code shows clearly what Ruby "thinks" about the identifiers used by us. It is also clear that the word "class" has a different meaning in Ruby. Let us explore with a fresh piece of sample code.

In the following runs, I have recursively dug through the Ruby’s inbuilt class hierarchy.

If we piece together the snippets, the following hierarchy emerges:

The reader is requested to carefully note the differences between "instance of" and "subclass of". The heavily self-referenced structure came into existence to implement a purely object-oriented language. Such a structure also allows meta programming. Changing of classes and objects in runtime!