From: Eli Bendersky Date: 2006-05-07T03:55:55+09:00 Subject: Re: Creating sub-classes using Struct Robert Klemme wrote: > 2006/5/6, Eli Bendersky : >> class Bar >> Another is dynamic creation of new classes using Struct: >> to do): >> >> >> How can this be done ? > > You'll have to modify Struct to be able to create sub classes of > arbitrary classes and not just Object. Btw, if feels a bit strange to > have a nested class that is a sub class of the outer class. By that > twist it contains itself - I think this is not a good idea. > Sorry, I don't understand what you mean by "have a nested class that is a sub class of the outer class". Perhaps it's better for me to explain the motivation for what I'm trying to do. Simplifying: I have a flat-file full of records. The way records are stored can be customized via a separate configuration file. I want to have a class Database which is a container of Record classes. The Record is best implemented as a Struct, IMHO, and I want to create the class dynamically after reading the configuration (which says which fields there are in a Record). I think it would be convenient for a Record to be a subclass of Database, since there is no point having Records without a Database. -- Posted via http://www.ruby-forum.com/.