Question

Hi Inside rails console you can get the result of the previous operation with _ Is there any way to do such a thing inside ruby program?

Was it helpful?

Solution

everything in Ruby is an object, so think about it, if any returned object is not assigned a reference then it will be marked for garbage collection, so no there is no way other than to assign a returned object to a variable!

OTHER TIPS

You can do this with irb (and programs that improve on irb) - it's not specific to Rails. But apart from that, I'm not aware of being able to do what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top