From: Gavin Sinclair Date: 2002-12-06T17:08:09+09:00 Subject: Re: Printing subclasses From: "ted" > Can Ruby print the subclasses of a given class? Like the reverse of the > example of Class#superclass in "Reflection, ObjectSace and Distributed > Ruby" in pickaxe. def subclasses(the_class) result = [] ObjectSpace.each_object(Class) do |klass| result << klass if klass < the_class end result end p subclasses(Numeric) # -> [Bignum, Float, Fixnum, Integer] Now I am justified in asking something that has bothered me for a while. Why can't ObjectSpace return an array of all objects of a given class/module. Then the whole method above would be written as: ObjectSpace.objects(Class).select { |klass| klass < the_class } Makes sense to me. Gavin