From: Thufir Date: 2007-11-08T12:28:42+09:00 Subject: Re: alternate to case; generating a list of sub-classes On Nov 7, 4:15 pm, Alex Fenton wrote: > Thufir wrote: > > The below uses pseudo-random number generation to populate an array > > with various monsters, all inherit from Creature. Can a list of > > classes which inherit from Creature be generated automagically? > > Perhaps: > > class Creature > @creature_classes = [] > # hook to note when a class inherits > def self.inherited(klass) > @creature_classes << klass > end [...] Aha, I've been trying to figure out what a "hook" meant! :) thanks, Thufir