Given a const how can I check whether the const exists
without rescuing an exception thrown - if it isn't?
(using const_set is not elegant since You have to supply a special value)
if const_defined?('SomeConst')
...
end
My next qusetion is:
Assuming there is a nested const:
Given a const how can I check whether the const exists
without rescuing an exception thrown - if it isn't?
(using const_set is not elegant since You have to supply a special value)
if const_defined?('SomeConst')
...
end
if defined?(SomeConst)
My next qusetion is:
Assuming there is a nested const:
Thanks for Your answer, but I think the first question is still open
since the Const is given as a String and the const_defined?
raises an error.
Of course a can catch it but on the other hand I don't know how exception mechanisms in Ruby affect performance.