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

I like your idea, though consider:

irb(main):001:0> class Base; end
=> nil
irb(main):002:0> class Derived < Base; end
=> nil
irb(main):003:0> sc = class << Derived; self; end
=> #<Class:Derived>
irb(main):004:0> ObjectSpace.each_object(sc) { |c| p c }
Derived
=> 1
irb(main):005:0> sc = class << Base; self; end
=> #<Class:Base>
irb(main):006:0> ObjectSpace.each_object(sc) { |c| p c }
Derived
Base
=> 2