From: duerst@... Date: 2015-04-20T08:14:14+00:00 Subject: [ruby-core:68935] [Ruby trunk - Feature #11076] Enumerable method count_by Issue #11076 has been updated by Martin D��rst. Having this would definitely be very useful. I remember having searched for a 'count_by' method more than once in the past. ---------------------------------------- Feature #11076: Enumerable method count_by https://bugs.ruby-lang.org/issues/11076#change-52200 * Author: Harald B��ttiger * Status: Open * Priority: Low * Assignee: ---------------------------------------- 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/