Skip to content

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

Open
@bo-tato

Description

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?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions