[#68845] [Ruby trunk - Feature #11056] [PATCH] lib/net/*: use io/wait methods instead of IO.select — normalperson@...
Issue #11056 has been updated by Eric Wong.
3 messages
2015/04/11
[#68945] [Ruby trunk - Feature #11083] [Open] Gemify net-telnet — shibata.hiroshi@...
Issue #11083 has been reported by Hiroshi SHIBATA.
4 messages
2015/04/21
[#68951] Re: [Ruby trunk - Feature #11083] [Open] Gemify net-telnet
— Eric Wong <normalperson@...>
2015/04/21
shibata.hiroshi@gmail.com wrote:
[#69012] [Ruby trunk - Feature #11105] [Open] ES6-like hash literals — shugo@...
Issue #11105 has been reported by Shugo Maeda.
5 messages
2015/04/29
[ruby-core:68941] [Ruby trunk - Feature #11076] Enumerable method count_by
From:
bottiger@...
Date:
2015-04-20 15:35:27 UTC
List:
ruby-core #68941
Issue #11076 has been updated by Harald B=C3=B6ttiger.
I am sorry but I am not sure to properly format this, but the documentation=
would be like:
Syntax:
group_by { |obj| block } =E2=86=92 a_hash
group_by =E2=86=92 an_enumerator
=20=20=20=20
Description:
Groups the collection by result of the block. Returns a hash where th=
e keys are the evaluated result from the block and the values are the numbe=
r of the elements in the collection that correspond to the key.
=20=20=20=20
If no block is given an enumerator is returned.
=20=20=20=20
Examples:
['a','a','a','b','c'].group_by { |x| x } #=3D> {'a'=3D>3, 'b'=3D>1, '=
c'=3D>1}
(1..7).group_by { |i| i%3 } #=3D> {0=3D>2, 1=3D>3, 2=3D>2}
----------------------------------------
Feature #11076: Enumerable method count_by
https://bugs.ruby-lang.org/issues/11076#change-52204
* Author: Harald B=C3=B6ttiger
* Status: Open
* Priority: Low
* Assignee:=20
----------------------------------------
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 =3D ['aa', 'aA', 'bb', 'cc']
p array.count_by(&:downcase) #=3D> {'aa'=3D>2,'bb'=3D>1,'cc'=3D>1}
~~~
--=20
https://bugs.ruby-lang.org/