From: Brian Candler Date: 2003-07-17T23:17:56+09:00 Subject: Re: reliable way of finding Objects Class? On Thu, Jul 17, 2003 at 11:08:00PM +0900, dblack@superlink.net wrote: > As for finding an object's class without Object#class, I guess you > could do something like: > > >> class Obj; def class; "Go away!"; end; end > => nil > >> o = Obj.new > => # > >> a = []; ObjectSpace.each_object(Class) {|c| a << c if o.is_a?(c)} > => 346 > >> a[-1] > => Obj "is_a?" matches superclasses as well - "instance_of?" would be better here I think. But like David says, if you shoot off all your feet, you won't have anything left to stand on :-) Cheers, Brian.