I am getting NameError: undefined local variable or method
with ruby 2.1.2
As observed in this question, expressions like:
bar if bar =
In 1.8.7
, 1.9.3
, 2.0.0
and even 2.1.1
I get 2 warnings and no errors:
2.0.0-p247 :007 > bar if bar = false
(irb):7: warning: found = in conditional, should be ==
=> nil
2.0.0-p247 :008 > bar if bar = true
(irb):8: warning: found = in conditional, should be ==
=> true
whereas in the 2.1.2
version you mention I get 2 warnings and 1 NameError
error.
2.1.2 :001 > bar if bar = true
(irb):1: warning: found = in conditional, should be ==
NameError: undefined local variable or method `bar' for main:Object
from (irb):1
from /home/durrantm/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `'
2.1.2 :002 > bar if bar = false
(irb):2: warning: found = in conditional, should be ==
=> nil
This is on my Ubuntu 14