Issue #11076 has been updated by odlp (Oliver Peate).


For me the definition of tally does seem to fit the use case, so +1 to `tally(_by)`.

One other suggestion - how about [census](https://www.merriam-webster.com/dictionary/census) (as in `census_by(&:downcase)`)? It's more widely used than tally (although I think tally is the better choice): 

[https://books.google.com/ngrams/graph?content=tally%2Ccensus%2Ccount&case_insensitive=on&year_start=1900&year_end=2008](https://books.google.com/ngrams/graph?content=tally%2Ccensus%2Ccount&case_insensitive=on&year_start=1900&year_end=2008)

----------------------------------------
Feature #11076: Enumerable method count_by
https://bugs.ruby-lang.org/issues/11076#change-75683

* Author: haraldb (Harald Bttiger)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I very often use `Hash[array.group_by{|x|x}.map{|x,y|[x,y.size]}]`.

Would be nice with to have a method called `count_by`:

~~~ruby
array = ['aa', 'aA', 'bb', 'cc']
p array.count_by(&:downcase) #=> {'aa'=>2,'bb'=>1,'cc'=>1}
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>