📜  使用 each_with_object ruby 对所有元素求和 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:28.806000             🧑  作者: Mango

代码示例1
You cannot use immutable objects like numbers. Example below does not return 55 but 0.

(1..10).each_with_object(0) do |item, sum|
  sum += item
end
 => 0