> If you wish. Note that you can't create constants from within methods.
I think what you mean is the dynamic constant assignment like so
def hi
ABC = "hi"
end
But you can generate them programmatically like so:
def test(arg)
_ = Object.const_set(arg.capitalize, "this is the constant
"+arg.capitalize)
end
test 'foo'
test 'bar'
puts Foo # "this is the constant Foo"
puts Bar # "this is the constant Bar"
I love constants btw I even abuse them and dont care that I do!

--
Posted via
http://www.ruby-forum.com/.