In Ruby 2.7, an explicit Hash (with curly braces) as the last argument is implicitly converted to kwargs.
In Ruby 3.0+, an explicit Hash (with curly braces) as the last argument is treated as a Hash literal, and can't be parsed as kwargs.
In Ruby 2.7, an explicit Hash (with curly braces) as the last argument is implicitly converted to kwargs.
In Ruby 3.0+, an explicit Hash (with curly braces) as the last argument is treated as a Hash literal, and can't be parsed as kwargs.
def test_kwargs_parsing(a, b, **kwargs) | |
print a, b, kwargs | |
end | |
# Ruby 2.7: 1, 2, {:c=>3, :d=>4} | |
# Ruby 3.1: 1, 2, {:c=>3, :d=>4} | |
test_kwargs_parsing(1, 2, c:3, d:4) | |
# Ruby 2.7: 1, 2, {:c=>3,:d=>4} | |
# Ruby 3.0+: wrong number of arguments (given 3, expected 2) (ArgumentError) | |
test_kwargs_parsing(1, 2, {c:3, d:4}) |