1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Assoc pattern matching (#3703)

[Feature #17260] One-line pattern matching using tASSOC

R-assignment is rejected instead.
This commit is contained in:
Nobuyoshi Nakada 2020-10-26 18:00:24 +09:00 committed by GitHub
parent cffdacb15a
commit 52c630da00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2020-10-26 18:00:56 +09:00
Merged-By: nobu <nobu@ruby-lang.org>
8 changed files with 37 additions and 65 deletions

View file

@ -9,11 +9,13 @@ ruby_version_is "2.7" do
ScratchPad.record []
end
it "can be standalone in operator that deconstructs value" do
eval(<<-RUBY).should == [0, 1]
[0, 1] in [a, b]
[a, b]
RUBY
ruby_version_is "3.0" do
it "can be standalone assoc operator that deconstructs value" do
eval(<<-RUBY).should == [0, 1]
[0, 1] => [a, b]
[a, b]
RUBY
end
end
it "extends case expression with case/in construction" do