[ruby-core:68932] [Ruby trunk - Feature #11076] [Open] Enumerable method count_by

From: bottiger@...
Date: 2015-04-19 20:38:55 UTC
List: ruby-core #68932
Issue #11076 has been reported by Harald B旦ttiger.

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

* 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`:

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



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

In This Thread

Prev Next