You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
foo(kw: 1) and foo({kw: 1}) will have different meanings in Ruby 3. And Ruby warns them since Ruby 2.7 if it is used unexpectedly, and Ruby raises an argument error in Ruby 3.
But the style guide says "always omit the curly braces".
So I propose revising the guide.
I think the guide should mention both cases, Hash and keyword arguments.
For example:
deffoo(a:,b:)pa,benddefbar(hash)phashend# goodfooa: 1,b: 2# goodbar({a: 1,b: 2})# bad - foo expects keyword arguments, but it passes a Hashfoo({a: 1,b: 2})# bad - bar expects a hash, but it passes keyword argumentsbara: 1,b: 2
The text was updated successfully, but these errors were encountered:
https://github.com/rubocop-hq/ruby-style-guide#no-braces-opts-hash
See also rubocop/rubocop#7641
foo(kw: 1)
andfoo({kw: 1})
will have different meanings in Ruby 3. And Ruby warns them since Ruby 2.7 if it is used unexpectedly, and Ruby raises an argument error in Ruby 3.But the style guide says "always omit the curly braces".
So I propose revising the guide.
I think the guide should mention both cases, Hash and keyword arguments.
For example:
The text was updated successfully, but these errors were encountered: