test if variable exists in ruby
Testing if a variable exists in ruby is pretty easy.
irb(main):001:0> defined? variablename
This will return if it's defined but not just variables but a few things
irb(main):001:0> defined? variablename
This will return if it's defined but not just variables but a few things
- "local-variable"
- "global-variable"
- nil # (undefined)
- "method"
- "super"
- "yield"
Comments