From: Gregory Seidman Date: 2006-05-01T20:59:26+09:00 Subject: Re: how to create Class object with name determined at runti On Mon, May 01, 2006 at 08:52:12PM +0900, Bill Roberts wrote: } John Johnson wrote: } > You can use eval() to do that, like so: } > irb(main):001:0> a='String' } > => "String" } > irb(main):002:0> b=eval("#{a}.new") } > => "" } > irb(main):003:0> b.class } > => String } > irb(main):004:0> } > } > In the second irb line, the contents of the variable _a_ are substituted } > in the string before the .new. It amounts to b=eval("String.new"). Avoid using eval when possible. irb(main):001:0> a='String' => "String" irb(main):002:0> b=Object::const_get(a).new() => "" irb(main):003:0> b.class => String irb(main):004:0> } > Regards, } > JJ } > } > } John - thanks, also a neat solution. Having had experience mainly in } static/compiled languages previously, I am just getting to grips with } Ruby's nice features for adapting itself as it runs. --Greg