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.
Written by Eric Raio
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#