From: "Jesús Gabriel y Galán" Date: 2008-11-19T19:50:30+09:00 Subject: Re: Is there a way to know what are the subclasses of a given class ? On Wed, Nov 19, 2008 at 11:36 AM, Michael Fellinger wrote: > On Wed, Nov 19, 2008 at 7:12 PM, Jesús Gabriel y Galán > wrote: > Little different style maybe: > > class A > @subclasses = [] > def self.inherited(into) @subclasses << into end > def self.subclasses() @subclasses end > end Yep, much cleaner :-). I made a mess while I was typing in irb about closing the << self early, and forgetting to initialize the array, so that was the result. I probably wanted to type this: irb(main):001:0> class A irb(main):002:1> class << self irb(main):003:2> attr_reader :subclasses irb(main):004:2> def inherited(child) irb(main):005:3> subclasses << child irb(main):006:3> end irb(main):007:2> end irb(main):008:1> @subclasses = [] irb(main):009:1> end but anyway your version is cleaner... Jesus.