Xavier Noria
11/21/2007 8:34:00 PM
On Nov 21, 2007, at 9:28 PM, Jamal Soueidan wrote:
> class MyClass
> ANYTHING = "huh"
> end
>
> How can I print out huh from string?
>
> MyClass::"anything".upcase
>
> Is there any way to do that ?
>
> :)
Sure, for example:
MyClass.module_eval("ANYTHING")
MyClass.const_get("ANYTHING")
In Rails you also have:
"MyClass::ANYTHING".constantize
-- fxn