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
···
On 23/10/06, Andrew Libby <alibby@tangeis.com> 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