IRB Tricks

Here's another cool trick I learned through pairing today during my apprenticeship. In IRB, you can use an underscore to retrieve your last return value. Seems like the perfect shortcut whenever you realize too late that you should have stored a value in a variable! Here's a quick example.

$ 1 + 2
=> 3
$ _ + 3
=> 6

Written on October 1, 2013