You can retrieve the result of previous command with _
In Ruby IRB sessions, you can retrieve the result of previous command with __
.
Here is an example:
irb(main):001> {test: "testing"}
=> {:test=>"testing"}
irb(main):002> test_hash = _
=> {:test=>"testing"}
irb(main):003> test_hash
=> {:test=>"testing"}
irb(main):004>
As you can see, if you forget to equate the previous result to a variable, you will still be able to retrieve it as opposed to rerunning an expensive command
Last Updated: 11/11/2023
Published: 11/11/2023