Continuing adventures in The Ruby Programming Language
Ruby doesn't like when you use variables or methods that aren't defined:
Ruby ❯ irb irb(main):001:0> a NameError: undefined local variable or method `a' for main:Object from (irb):2 from /Users/clint/.rbenv/versions/1.9.3-dev/bin/irb:12:in `<main>'
Makes sense –
a doesn't exist. However, if the interpreter has at
a, things will be different:
Ruby ❯ irb irb(main):003:0> if false irb(main):004:1> a = true irb(main):005:1> end => nil irb(main):006:0> a => nil
a is never assigned, but it's still seen by the interpreter, so
it still exists in some way.