mirror of
https://github.com/ruby/ruby.git
synced 2025-09-22 03:53:58 +02:00
Add pattern matching pin support for instance/class/global variables
Pin matching for local variables and constants is already supported, and it is fairly simple to add support for these variable types. Note that pin matching for method calls is still not supported without wrapping in parentheses (pin expressions). I think that's for the best as method calls are far more complex (arguments/blocks). Implements [Feature #17724]
This commit is contained in:
parent
f1035248af
commit
fa87f72e1e
Notes:
git
2021-07-16 01:56:27 +09:00
5 changed files with 79 additions and 2 deletions
|
@ -400,6 +400,30 @@ END
|
|||
a == 0
|
||||
end
|
||||
end
|
||||
|
||||
assert_block do
|
||||
@a = /a/
|
||||
case 'abc'
|
||||
in ^@a
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
assert_block do
|
||||
@@TestPatternMatching = /a/
|
||||
case 'abc'
|
||||
in ^@@TestPatternMatching
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
assert_block do
|
||||
$TestPatternMatching = /a/
|
||||
case 'abc'
|
||||
in ^$TestPatternMatching
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_pin_operator_expr_pattern
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue