I'm finding it difficult to understand how the following variable is being set to nil, while it seems that it isn't assigned anywhere.
I have tried this in ruby 2.1.2 and in ruby 1.8.7. Both yield the same results.
How is this happening?
irb(main):002:0> foo
NameError: undefined local variable or method `foo' for main:Object
irb(main):003:0> if false
irb(main):004:1> foo = 1
irb(main):005:1> end
irb(main):006:0> foo
=> nil