Skip to content

Commit 653fbca

Browse files
authored
Merge pull request #2265 from pocke/tally
Add Enumerable#tally since Ruby 2.7
2 parents e573fdb + 674f91f commit 653fbca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

refm/api/src/_builtin/Enumerable

+14
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,20 @@ init 引数を明示的に指名すると数値以外のオブジェクトにも
17771777
"+" メソッドが再定義されている場合、Enumerable#sum は再定義を無視することがあります(例えばInteger#+)。
17781778

17791779
@see [[m:Array#sum]]
1780+
1781+
#@since 2.7.0
1782+
--- tally -> Hash
1783+
1784+
self に含まれる要素を数え上げた結果を Hash で返します。
1785+
Hash のキーは self に含まれる要素で、Hash の値は対応する要素が出現する回数です。
1786+
1787+
要素は[[m:Object#eql?]]で比較されます。
1788+
1789+
#@samplecode 例
1790+
["a", "b", "c", "b"].tally #=> {"a"=>1, "b"=>2, "c"=>1}
1791+
#@end
1792+
#@end
1793+
17801794
--- uniq -> Array
17811795
--- uniq { |item| ... } -> Array
17821796

0 commit comments

Comments
 (0)