Ruby 2.7 Enumerable#tally
Have you ever wanted to get back a count of how often objects showed up within an array? If so, you've likely written (or copy-pasta'd) some variation of the code below:
Lucky for us, Ruby 2.7 introduces a new convenience method in Enumerable#tally
, so our above code reduces to:
Huzzah!
You can read the feature discussion here!
Tweet