IRB: last return value

Posted . Visible to the public.

In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This might come in handy if you forgot to save the value to a variable and further want to use it.

Example:

irb(main):001:0> 1 + 2
=> 3
irb(main):002:0> _
=> 3
irb(main):003:0> a = _
=> 3
Daniel Straßner
Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Daniel Straßner to makandra dev (2017-07-24 06:38)