Console tip: retrieve the last return value with underscore
2 years ago • 22 notesIn IRB you can retrieve the last return value from a command by using the underscore
_sign:$ irb >> 2*3 => 6 >> _ + 7 => 13 >> _ => 13This also works in the Rails console:
$ script/console >> User.first => #<User id: 7, first_name ... >> user = _ => #<User id: 7, first_name ... >> user => #<User id: 7, first_name ...This is quite useful, when you forgot to assign the return value of an expression to a variable.