mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Escape Binding
reference in pattern matching docs
This commit is contained in:
parent
80ab42462e
commit
99503ab975
Notes:
git
2025-03-21 01:36:29 +00:00
1 changed files with 2 additions and 2 deletions
|
@ -221,7 +221,7 @@ For hash patterns, even a simpler form exists: key-only specification (without a
|
|||
end
|
||||
#=> "matched: 1"
|
||||
|
||||
Binding works for nested patterns as well:
|
||||
\Binding works for nested patterns as well:
|
||||
|
||||
case {name: 'John', friends: [{name: 'Jane'}, {name: 'Rajesh'}]}
|
||||
in name:, friends: [{name: first_friend}, *]
|
||||
|
@ -249,7 +249,7 @@ The "rest" part of a pattern also can be bound to a variable:
|
|||
end
|
||||
#=> "matched: 1, {b: 2, c: 3}"
|
||||
|
||||
Binding to variables currently does NOT work for alternative patterns joined with <code>|</code>:
|
||||
\Binding to variables currently does NOT work for alternative patterns joined with <code>|</code>:
|
||||
|
||||
case {a: 1, b: 2}
|
||||
in {a: } | Array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue