Hi,
My question is really simple
class MyClass
ANYTHING = “huh”
end
How can I print out huh from string?
MyClass::“anything”.upcase
Is there any way to do that ?
Thanks for help…
Hi,
My question is really simple
class MyClass
ANYTHING = “huh”
end
How can I print out huh from string?
MyClass::“anything”.upcase
Is there any way to do that ?
Thanks for help…
Jamal S. wrote:
MyClass::“anything”.upcase
Is there any way to do that ?
MyClass.const_get(“anything”.upcase)
HTH,
Sebastian
On Nov 21, 2007, at 9:28 PM, Jamal S. wrote:
Sure, for example:
MyClass.module_eval(“ANYTHING”)
MyClass.const_get(“ANYTHING”)
In Rails you also have:
“MyClass::ANYTHING”.constantize
– fxn
Thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs