Paul Brannan wrote:
> On Thu, Sep 18, 2008 at 06:07:29AM +0900, Thomas B. wrote:
>> Why complicate?
>> 
>> a=anything
>> ec=class<<a;self;end
>> a_=nil
>> ObjectSpace.each_object(ec){|aa| a_=aa}
>> a.equal?(a_) #=> true
> 
> irb(main):006:0> ObjectSpace.each_object(sc) { |c| p c }
> Derived
> Base
> => 2

You're right. I was thinking about "regular" object's eigenclasses and 
not eigenclasses of classes, and with them I think my solution will 
work. My mistake.

But now I finally understand the remark I read somewhere and ignored, 
because I didn't think it was important. It said that the "method 
lookup" for classes includes eigenclasses of their ancestors.

Now I'm wondering if it is possible to construct such an object that 
belong to a foreign eigenclass and not be a class itself. In other 
words, how to make my code fail even though a is not a Class. Any ideas?

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