On Sat, 13 Jan 2001 00:17:55 +0900, Dave Thomas wrote: > > I have a class name in a string, and I want to create an instance of that > > class. Can I do so without using eval? I'm looking for something like > > Java's "Class.forName(className)" or Smalltalk's "Smalltalk classNamed: > > className". > > I have to say that this concept strikes me as being really very > risky. However... > > def forName(className) > ObjectSpace.each_object(Class) do |c| > return c if c.name == className > end > raise "Class #{className} not found" > end i think this may have been what i was originally trying to ask :) it's nice to know that ruby is flexible enough for those that might want to hang themselves with questionable code... -- *---------------------------------------- | |http://www.biosys.net/snowzone | |remove myspleen to email | *-----------------------