Allow inspecting implicit parameters via `implicit_parameter_get` etc.

未关闭
#1,210 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
ruby
领域
cli, devtools

调研方向

首先阅读链接的 Ruby issue 中引用的 Ruby 4.0 隐式参数查询方法,以及示例中展示的 binding.irb 行为。跟踪 IRB 如何求值 it 和 _1 等名称,然后验证 implicit_parameter_get 及相关方法可以在不重写 block 的情况下从会话中检查它们。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Ruby
星标
477
派生
165
平均合并
1 天 19 小时
30 天内合并 PR
5

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/irb 的其他 Issue

查看 ruby/irb 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。