ruby
ruby copied to clipboard
Support binding to non-local vars in pattern matching
Examples:
case %w[a b c]
in [@a, $b, *@@rest]
end
@a #=> 'a'
$b #=> 'b'
@@rest #=> ['c']
Using vars in alt pattern is prohibited (similarly to the current behaviour for local vars).
Implements https://bugs.ruby-lang.org/issues/18408.
P.S. This brings back rightward assignment: 42 => @v.
Could you add specs for this in spec/ruby/language/pattern_matching_spec.rb ?
@eregon Done!