Hi --

On Wed, 20 Nov 2002, ahoward wrote:

> On Wed, 20 Nov 2002, Joel VanderWerf wrote:
>
> J> Instead of
> J>
> J>    s.intern.value
> J>
> J> Try
> J>
> J>    eval s
> J>
> J> or
> J>
> J>    eval s.intern.to_s
>
> hmmm.  this does work, but the string eval'd is actually dynamically generated
> from a cgi program - so i'd like to do it safely.  i could do
>
>   if Class === (klass = (eval s.intern)).type
>     object = klass.new
>   end
>
> and at least know it was a class - but i've already evaluated the string at
> this point...

Actually this:

  Class === obj.type

is always true, because it's testing to see whether obj.type is a
Class.

Maybe you could do:

  if Class === const_get(s)
    obj = s.new
  end


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav