Just curious about it.
If you open the IRB and type _
, you'll get nil
as response:
irb(main):001:0> _
=> nil
And you can modify its value:
irb(main):002:0> _ = 'some value'
irb(main):003:0> _
=> "some value"
But if you create a new variable with _
, its value is modified:
irb(main):004:0> foo_bar = 'other value'
irb(main):005:0> _
=> "other value"
Why? Is this a design decision?
irb
uses_
to refer to the value of last calculated expression. So you will see_
changed even if you don't use it in the previous line :)