From: Robert Klemme Date: 2005-02-12T21:54:59+09:00 Subject: Re: Creating objects from a template "David McCabe" schrieb im Newsbeitrag news:1108179699.496561.195290@l41g2000cwc.googlegroups.com... > Robert's solution seems to do exactly what I want. Hurrah! > > The only thing I'm changing is making a hash with the new classes so > that I can instantiate them easily given their names: > > Object.const_set klass_name, klass > kinds[klass_name.intern] = klass > > called_for = :LongRange > p kinds[called_for].new > > If this isn't the Right Thing in ruby, any pointers on better ways to > do it would be appreciated. IMHO you don't need the hash. That's duplicating efforts the interpreter does for you already. You can just use the class name: # called_for can be a Symbol or String Object.const_get(called_for).new Kind regards robert