Skip to content
New issue

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

Handle to_h with block in Rails/IndexBy and Rails/IndexWith #324

Merged
merged 1 commit into from
Aug 11, 2020

Commits on Aug 11, 2020

  1. Handle to_h with block in IndexBy and IndexWith

    Since Ruby 2.6, `Enumerable#to_h` accepts a block which is called with
    each element and must return a key and value to include in the new hash.
    
    If the element is always returned as either the key or the value, using
    `Enumerable#index_by` or `Enumerable#index_with` is faster and clearer.
    
    This is similar to the existing logic that detects `map { ... }.to_h`.
    eugeneius committed Aug 11, 2020
    Configuration menu
    Copy the full SHA
    98c6570 View commit details
    Browse the repository at this point in the history