From: "alanwu (Alan Wu) via ruby-core" Date: 2025-01-14T17:11:33+00:00 Subject: [ruby-core:120666] [Ruby master Bug#20955] Subtle differences with Proc#parameters for anonymous parameters Issue #20955 has been updated by alanwu (Alan Wu). Status changed from Open to Closed AFAICT #20974 fully addressed the issue in the OP, and `it` behaves the same as anonymous destructuring parameters. ```shell $ ./miniruby -ve 'p proc { it }.parameters #=> [[:opt, nil]] p lambda { it }.parameters #=> [[:req]]' ruby 3.5.0dev (2025-01-14T16:46:11Z master b076e9b7ac) +PRISM [arm64-darwin24] [[:opt]] [[:req]] ``` ---------------------------------------- Bug #20955: Subtle differences with Proc#parameters for anonymous parameters https://bugs.ruby-lang.org/issues/20955#change-111491 * Author: zverok (Victor Shepelev) * Status: Closed * ruby -v: ruby 3.4.0dev (2024-12-15T13:36:38Z master 366fd9642f) +PRISM [x86_64-linux] * Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED ---------------------------------------- ```ruby 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. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/