Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

last result in Ruby REPL

In the Scala REPL if you evaluate something its value is stored in res{N}, as is discussed here: How can I access the last result in Scala REPL?. Is there a similar feature for the ruby REPL, or do the results get lost if you don't capture their value in a variable?

like image 519
Max DeLiso Avatar asked Jul 27 '26 15:07

Max DeLiso


1 Answers

You can use the underscore _ in irb to refer to the last returned result:

1 + 5
# => 6

_ + 10
# => 16
like image 60
Zach Kemp Avatar answered Jul 30 '26 08:07

Zach Kemp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!