Last Updated: February 25, 2016
·
2.339K
· ericraio

Underscore Trick in IRB/Rails Console

When you type _ in IRB or Rails console this is a place holder variable for the last return value.

For Example in Rails Console.

if I type

SomeModel.first

then I type

x = _

x is now assigned to SomeModel.first.

You can also use _ as a quick assignment into arguments of methods as well.