Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last result special variable _ sometimes returns second to last result at the end #2284

Open
bo-tato opened this issue Jul 28, 2023 · 0 comments

Comments

@bo-tato
Copy link

bo-tato commented Jul 28, 2023

if you start pry with: pry -e 'END {puts "last result was: #{_}"}'
if I exit pry with Control-D (EOF) it prints the second to last result:

[2] pry(main)> 1
=> 1
[3] pry(main)> 2
=> 2
[4] pry(main)> 3
=> 3
[5] pry(main)> ^D
last result was: 2

if I exit pry with exit then it does print the actual last result. If instead of _ I use _out_[-1] then it prints the correct last result whether I exit with Control-D or exit. Am I misunderstanding _ or is this some edge case bug for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant