From: Robert Klemme Date: 2009-08-13T05:55:09+09:00 Subject: Re: Class#descendants? On 12.08.2009 21:57, Jason Lillywhite wrote: > Robert Klemme wrote: > >> ObjectSpace.each_object(Class) do |cl| >> cl.superclass.ancestors.each {|scl| h[scl] << cl} >> end > > I'm getting this error: > > irb(main):085:0> ObjectSpace.each_object(Class) do |cl| > irb(main):086:1* cl.superclass.ancestors.each {|scl| h[scl] << cl} > irb(main):087:1> end > NoMethodError: undefined method `ancestors' for nil:NilClass > from (irb):86 > from (irb):85:in `each_object' > from (irb):85 > from :0 > > Is there a reason superclass is returning nil on cl? Oops, I inserted "superclass" after doing the test. This is likely the case of Object. If you remove it it works as well. Sorry, for the hassle. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/