On Fri, 5 May 2006, Gregory Seidman wrote: > On Fri, May 05, 2006 at 03:51:39AM +0900, RGR wrote: > } I want to create an object from a class, but the name of that class is > } in a variable, so the form obj=Class.new(args) can't be used. How can it > } be done? Without using eval, because its a bit messy and unelegant. > } > } The equivalent of obj=$variable_with_class_name(args) in php. > > obj = Object::const_get(class_name).new(args) mussel:~ > irb -r digest/md5 irb(main):001:0> Digest::MD5.to_s => "Digest::MD5" irb(main):002:0> obj = Object::const_get("Digest::MD5").new(args) NameError: wrong constant name Digest::MD5 from (irb):2:in `const_get' from (irb):2 from :0 it needs to be a bit smarter than that. regards. -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama