DEV Community

loading...

Get last returned value in the console

gadimbaylisahil profile image Sahil Gadimbayli ・1 min read

It happens that when we are working on the console we need to make use of last return value. It is also annoying when we forget to assign it to a variable to make use of it and have to type/copy it all over again.

When this happens, we can conveniently use underscore _ to retrieve the last return value.

$ irb

['I am last returned array']
_
['I am last returned array']
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide