James Gray
2/23/2006 3:43:00 PM
On Feb 23, 2006, at 9:37 AM, Michael Trier wrote:
> Just learning, but what's wrong with eval? I do something like the
> following in order to convert from a string to an object of the type
> specified by the string:
>
> a = "MyClass"
> my_class = eval(a)
> my_class.to_s
eval() is a very powerful tool that we probably shouldn't use unless
we absolutely need too. What if the String contains typos or
malicious code? Also, it should be slower to compile and run some
code that to just do a constant lookup. Probably better to use the
tools intended for the operation is all.
James Edward Gray II