Creating objects type only known at runtime

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

On 23/10/06, Andrew L. [email protected] wrote:

o = Object.const_get(class_name).new

Farrel

Farrel L. wrote:

seems inelegant.

o = Object.const_get(class_name).new

Farrel

Thanks!!