Actions
Bug #20955
closedSubtle differences with Proc#parameters for anonymous parameters
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-12-15T13:36:38Z master 366fd9642f) +PRISM [x86_64-linux]
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:
- For proc, unlike numbered parameters, the parameter name is
nil
(notit
). This, though, can be justified to distinguish fromproc { |it| }
case - But also,
proc
has thisnil
for a parameter name, whilelambda
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.
Actions
Like0
Like0Like0Like0Like0Like0Like0Like1Like1