Project

General

Profile

Actions

Bug #20955

closed

Subtle differences with Proc#parameters for anonymous parameters

Added by zverok (Victor Shepelev) 4 days ago. Updated about 7 hours ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-12-15T13:36:38Z master 366fd9642f) +PRISM [x86_64-linux]
[ruby-core:120252]

Description

p proc { |x| }.parameters   #=> [[:opt, :x]]
p lambda { |x| }.parameters #=> [[:req, :x]]
p proc { _1 }.parameters    #=> [[:opt, :_1]]
p lambda { _1 }.parameters  #=> [[:req, :_1]]
p proc { it }.parameters    #=> [[:opt, nil]]
p lambda { it }.parameters  #=> [[:req]]

Note the last pair; here are two small confusing problems:

  1. For proc, unlike numbered parameters, the parameter name is nil (not it). This, though, can be justified to distinguish from proc { |it| } case
  2. But also, proc has this nil for a parameter name, while lambda has not.

I am not sure what the “most logical” thing to do here, but I believe that at least proc { it } and lambda { it } should be made consistent with each other.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #18980: `it` as a default block parameterClosedk0kubun (Takashi Kokubun)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like1Like1