Count By Property

Count occurrences of array elements grouped by a specified property.

Code

General
arr.map { |item| item[key] }.tally

Parameters

Array of objects

Property to count by

Server

More Ruby Snippets