From: keystonelemur@... Date: 2018-12-13T00:23:28+00:00 Subject: [ruby-core:90462] [Ruby trunk Feature#11076] Enumerable method count_by Issue #11076 has been updated by baweaver (Brandon Weaver). @matz / @ko1: Any chance of this making it into 2.6? The code is already done (thanks @nobu) and the only consideration left is the name. Would `tally_by` be an acceptable compromise? ---------------------------------------- Feature #11076: Enumerable method count_by https://bugs.ruby-lang.org/issues/11076#change-75622 * Author: haraldb (Harald B��ttiger) * 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: