From: James Britt Date: 2005-06-05T22:51:42+09:00 Subject: Re: Creating objects from strings. Bill wrote: > Hi, > > I'm a Java programmer that is trying to learn Ruby. > > I'm trying to write a container that creates objects on the fly from a > descriptor. In Java I'd simply do Class.forName("MyClass").newInstance(); mc = Object.const_get( "MyClass" ).new This presumes that the code already knows about the class MyClass (e.g., because the class is defined in the same file, or defined in a file that has already been read using 'require' or 'load'). BTW, I looked at the Ruby FAQ, and this question doesn't seem to be in there, despite its popularity. http://dev.rubycentral.com/faq/ James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys