Paul Brannan [2008-09-18 20:23]: > 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 good catch! but this should work then: irb(main):006:0> ObjectSpace.each_object(sc) { |c| p c if sc.equal?(class << c; self; end) } Base => 2 i'll update my implementation in ruby-nuggets tomorrow (moving the check that i'm doing anyway inside the loop; thanks). cheers jens