module GemFootprintAnalyzer::CoreExt::Array
Provides Array#sum
, missing in Ruby 2.2.0
Public Instance Methods
sum(init = 0) { |el| ... }
click to toggle source
Sums over the array
# File lib/gem_footprint_analyzer/core_ext/array.rb, line 6 def sum(init = 0, &block) if block reduce(init) { |acc, el| acc + yield(el) } else reduce(init) { |acc, el| acc + el } end end