We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hash#values_at
Use Hash#values_at or Hash#fetch_values when you need to retrieve several values consecutively from a hash.
Hash#fetch_values
https://rubystyle.guide/#hash-values-at-and-hash-fetch-values
# bad email = data['email'] username = data['nickname'] # bad keys = %w[email nickname].freeze email, username = keys.map { |key| data[key] } # good email, username = data.values_at('email', 'nickname') # good keys = %w[email nickname].freeze email, username = data.values_at(*keys)
The text was updated successfully, but these errors were encountered:
I am not sure that this rule does not conflict with the Style/ParallelAssignment cop.
Style/ParallelAssignment
Sorry, something went wrong.
Good point. It may be beneficial to re-review the https://rubystyle.guide/#hash-values-at rule in the style guide again before suggesting the cop implementation. Actually, it conflicts with the https://rubystyle.guide/#parallel-assignment rule as well.
Done. rubocop/ruby-style-guide#936
No branches or pull requests
Description
Use
Hash#values_at
orwhen you need to retrieve several values consecutively from a hash.Hash#fetch_values
https://rubystyle.guide/#hash-values-at-and-hash-fetch-values
Behavior
The text was updated successfully, but these errors were encountered: