From: "rpardee@..." Date: 2009-01-24T10:28:08+09:00 Subject: Re: instantiate a class dynamically On Jan 23, 5:25 pm, "F. Senault" wrote: > Le 24 janvier 2009 02:12, rpar...@gmail.com a crit : > > > Hey All, > > > If I have the name of a class in a string var, is it possible to get a > > new instance of that class (and if so, how)?  The following do *not* > > work: > > >   my_string = "Hash" > > >   my_object = Class(my_string) > >   my_object = Class.new(my_string) > >   my_object = Object.new(my_string) > > my_object = Object.const_get(my_string.to_sym).new > > (The to_sym is mandatory in ruby 1.9.) > > Fred > -- > Any time tomorrow a part of me will die > And a new one will be born > Any time tomorrow  I'll get sick of asking why > Sick of all the darkness I have worn            (K's Choice, Shadow Man) Awesome cool--looks like I can even pass arguments into new() (which would have been my next question). Thanks very much! -Roy