Hi --

On Mon, 2 Oct 2006, Robert Dober wrote:

> On 10/2/06, dblack / wobblini.net <dblack / wobblini.net> wrote:
>> 
>> Hi --
>> 
>> 
>> class C; end
>> class D < C; end
>> 
>> d = D.new
>> sing = class << d; self; end
>> 
>> p D.new.instance_of?(C)      # false
>> p D.new.instance_of?(D)      # true
>> p D.new.instance_of?(sing)   # false
>> 
>> So thinking of the singleton class as a subclass of the object's class
>> might be a little misleading, since the object still relates to its
>> "birth class" at only one level of remove.
>
>
> Of course, but  what I am puzzeled about is, why you use #instance_of?, well
> not really, because that was how the argument began.
> As a matter of fact let me be more humble ;)
> I am afraid I missed something basic in the discussion, because to my
> understanding #instance_of? is irrelevant and #is_a?
> is what we are interested in, no? (obviously no ;).

I was responding to Timothy's description of the default object main
as an instance of its singleton class.  My point was that the
relationship between an object and its singleton class is not actually
defined by Ruby as a class-instance relationship, though of course it
is very similar to such a relationship in many ways.


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org