From: "F. Senault" Date: 2009-01-24T10:28:07+09:00 Subject: Re: instantiate a class dynamically Le 24 janvier 2009 � 02:12, rpardee@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)