From: Sean Chittenden Date: 2002-04-28T08:57:50+09:00 Subject: Re: string to class? > > I've got a string, and I'd like to get a class reference. > > It's probably easy; I just haven't found the right methods yet. > > > > Example: > > # given 'Array' string, make a new Array > > str = "Array" > > aclass = something_or_other(str) > > a = aclass.new > > > > I can turn it into a symbol, and back to a string, > > and have thought about 'send'ing a 'class' message, > > but there's still a big chasm between me > > and the desired result! :-) > > You can always do: > > str = "Array" > aclass = eval(str) > a = aclass.new eval has always struck me as evil (are my perl roots showing?). Try: str = 'Array' m = Kernel.method(str) a = m.call(nil) a.push('foobar') p a -sc -- Sean Chittenden