From: Brian Candler Date: 2003-07-01T05:01:08+09:00 Subject: Re: dynamic object creation On Tue, Jul 01, 2003 at 01:22:22AM +0900, stefano wrote: > On Mon, 30 Jun 2003 15:49:05 +0000, Aryeh Friedman wrote: > > > If I have something like this: > > > > s="Array" > > > > How whould I get something like this: > > > > aObject=s.new > > > > In "plain" english I am asking if I have a valid name of a class in a > > string how do I create an instance of the class the string contains? > > s = "Array" > aObject = eval(s).new ... and just hope nobody passes in s = "`rm -rf /*`" as a class name :-| const_get will be much faster too, as it doesn't have to compile a piece of code each time.