エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
Ruby 2.4 implements Enumerable#sum
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Ruby 2.4 implements Enumerable#sum
It is a common use case to calculate sum of the elements of an array or valuesfrom a hash. [1, 2,... It is a common use case to calculate sum of the elements of an array or valuesfrom a hash. [1, 2, 3, 4] => 10{a: 1, b: 6, c: -3} => 4Active Support already implementsEnumerable#sum > [1, 2, 3, 4].sum #=> 10> {a: 1, b: 6, c: -3}.sum{ |k, v| v**2 } #=> 46> ['foo', 'bar'].sum # concatenation of strings #=> "foobar"> [[1], ['abc'], [6, 'qwe']].sum # concatenation of arrays #=> [1, "abc", 6, "qwe"]Unti