-
Getting a Count of Occurrences of Items in a Ruby Array (and a Caveat for Rails)
I feel like I’m often wanting to count occurrences of items in an array (Rails has its own special case as well), and I’m always trying to do it the “long way.” I finally stumbled upon this answer on StackOverflow that details the version-by-version options: Ruby 2.7+ use .tally directly on the array: Ruby 2.4+ […]