Skip to content

Allow inspecting implicit parameters via implicit_parameter_get etc. #1210

Description

@Earlopain

Currently, it is not possible to know what implicit parameters like it/_1 actually are. If I want to know, I have to rewrite the block to take explicit parameters.

[1, 2, 3].each do
  puts it
  binding.irb
end
$ ruby test.rb
1

From: test.rb @ line 3 :

    1: [1, 2, 3].each do
    2:   puts it
 => 3:   binding.irb
    4: end

irb(main):001> it
/home/user/code/test/test.rb(irb):1:in 'block in <main>': undefined local variable or method 'it' for main (NameError)
        from test.rb:3:in 'Binding#irb'
        from test.rb:3:in 'block in <main>'
        from test.rb:1:in 'Array#each'
        from test.rb:1:in '<main>'

Ruby 4.0 actually added methods to interogate the values of such params (https://bugs.ruby-lang.org/issues/21049#note-7) and it would be great if it can just work in irb.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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