On Jan 2, 2004, at 21:25, Chris Morris wrote:

> I've got the following code:
>
>    class Main
>      @@classes = []
>          def Main.classes
>        @@classes
>      end
>    end
>
>    class Root
>      Main.classes << self
>    end

class Root
   Main.classes << self
   def self.inherited(sub_class)
     Main.classes << sub_class
   end
end


>
>    class A < Root
>    end
>
>    class B < Root
>    end
>
>    puts Main.classes.inspect
>
>
> I'd like Main.classes == [Root, A, B], but currently it only is 
> [Root]. I understand why, but was wondering if there was an elegant 
> way to get what I'd like to have.
>
> I know in this example, I could simply add "Main.classes << self" to 
> each subclass, but, hey, that's way too much repetition for the 21st 
> century. :-)
>
> -- 
> Chris
> http://clabs.org/blogki
>
>
>
>

Sincerely,
Gennady Bystritsky