From: Andrew Libby Date: 2006-10-23T23:16:10+09:00 Subject: Re: creating objects type only known at runtime Farrel Lifson wrote: > On 23/10/06, Andrew Libby wrote: >> >> This weekend I was playing around with some ruby and wanted >> to create objects whose types were only known at runtime. >> The method I wound up using was >> >> o = eval "#{class_name}.new" >> >> Is this a preferred method. I come from (mostly) a perl >> background, but also a Java background. To me this approach >> seems inelegant. >> >> Thanks for any input. >> >> Andy >> >> -- >> Andrew Libby >> Tangeis, LLC >> Innovative IT Management Solutions >> alibby@tangeis.com >> >> > > o = Object.const_get(class_name).new > > Farrel > Thanks!! -- Andrew Libby Tangeis, LLC Innovative IT Management Solutions alibby@tangeis.com