Allow value omission in Hash literals

`{x:, y:}` is a syntax sugar of `{x: x, y: y}`.
This commit is contained in:
Shugo Maeda 2021-09-11 18:49:12 +09:00
parent 64e056a4c5
commit c60dbcd1c5
No known key found for this signature in database
GPG key ID: 2DFE34085E97CE47
2 changed files with 26 additions and 0 deletions

View file

@ -2178,4 +2178,21 @@ class TestHash < Test::Unit::TestCase
end;
end
end
def test_value_omission
x = 1
y = 2
assert_equal({x: 1, y: 2}, {x:, y:})
assert_equal({one: 1, two: 2}, {one:, two:})
end
private
def one
1
end
def two
2
end
end