4 ms·
`_` being assigned the result of the last statement evaluated is an IRB feature [1], not a ruby feature - hence the note that it is not a universal solution. [
by jordoh 6y ago
`_` being assigned the result of the last statement evaluated is an IRB feature [1], not a ruby feature - hence the note that it is not a universal solution.
[1]: https://github.com/ruby/irb/blob/master/lib/irb/context.rb#L344 https://github.com/ruby/irb/blob/master/lib/irb/context.rb#L...
- stouset 6y agoSo? Why does this need to be in the language when both major REPLs already support it? Why must this be yet another alternative way to accomplish the same thing as the way that’s existed since the first days of the language? There is no argument in favor of this addition. It doesn’t allow anything new, it provides a pointless alternative to the current way of doing things, and the one situation where it’s useful—REPLs—there’s already a feature that renders it completely unnecessary.
- jordoh 6y agoFor better or worse, providing multiple ways to do the same thing is part of ruby's philosophy. [1] [1]: https://www.artima.com/intv/ruby.html https://www.artima.com/intv/ruby.html