From: Pit Capitain Date: 2006-08-14T08:14:28+09:00 Subject: Re: Automatic instantiation of subclasses Sorry for answering late, I've been away for a week. Kilivor Kante schrieb: > First sorry I am a beginner ;-( What I want to do is: automatically > instantiate subclasses of a given class, say, A. > > class A > end > > class A1 < A > end > > class A2 end > > So I want to know the names of A subclasses: A1 and A2. Then instantiate > via reflection. Is it possible? > > Using ObjectSpace it is possible to know all the instantiated objects of > a class. But here no objects yet. In Ruby, classes are first-class objects ;-) ObjectSpace.each_object( class << A; self; end ) do |c| p c end Regards, Pit