Currently if it doesn’t exists I get a the undefined local variable or method error.
How can I check the value of the variable and also account for it not existing at all.
I thought && was the deal but:
if defined? aaa && aaa == '123' then puts aaa end
NameError: undefined local variable or method `aaa' for main:Object
In this case, you need the parenthetical like
defined?(aaa)otherwise it is evaluating the entire expressionaaa && aaa == '123'as if it weredefined?(aaa && aaa == '123'). So your code is really doing this: