In a recent thread titled "Unexpected results from private_methods", I
questioned the methods available for a BasicObject.  That led to an
interesting comment about BasicObject's place in the object model.

The comment (paraphrased) was:

>  BasicObject is a class, an instance of Class.
>  Class inherits from Object.
>
>  Almost everything in ruby is an object--including
>  classes.  All objects inherit from Object.
>
>  Things are very "circular" at the top of the ruby object model.
>  BasicObject is an object, it inherits from Object.  Object,
>  in turn, inherits from BasicObject, which means
>  BasicObject inherits from itself!

I get the conceptual drift, but I wonder about the practical
implications.  So I ran a bit of code to try to understand better, and
just confused myself more.  Specifically, I ran code to determine
BasicObject's class, superclass and ancestors, and whether BasicObject
is an instance or kind of BasicObject, Object and/or Class.

The results SEEM inconsistent to me (probably because of my limited
understanding).

  BasicObject's class is Class
  BasicObject's superclass is
  BasicObject's ancestors are [BasicObject]
  BasicObject kind of BasicObject? true
  BasicObject instance of BasicObject? false
  BasicObject kind of Object? true
  BasicObject instance of Object? false
  BasicObject kind of Class? true
  BasicObject instance of Class? true

Do these results seem inconsistent to anyone else?


j

James D. Maher
jdmaher / jdmaher.com

-- 
Posted via http://www.ruby-forum.com/.