mirror of
https://github.com/ruby/ruby.git
synced 2026-01-28 13:04:22 +00:00
Blocks and lambdas inherit anonymous arguments from the method they are a part of.
They themselves don't allow to introduce new anonymous arguments.
While you can write this:
```rb
def foo(*)
bar { |**| }
end
```
referecing the new parameter inside of the block will always be a syntax error.
https://github.com/ruby/prism/commit/2cbd27e134
28 lines
177 B
Plaintext
28 lines
177 B
Plaintext
->(
|
|
foo
|
|
) {}
|
|
|
|
->(x: "b#{a}") { }
|
|
|
|
->(a: b * 3) {}
|
|
|
|
-> foo = bar do end
|
|
|
|
-> foo: bar do end
|
|
|
|
def foo(*, **)
|
|
->() { bar(*, **) }
|
|
end
|
|
|
|
p{|a:
|
|
b|}
|
|
|
|
->(a:
|
|
b){}
|
|
|
|
->a:
|
|
b{}
|
|
|
|
->a:
|
|
{}
|