Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/array_helper.rb
Instance Method Summary collapse
Instance Method Details
#reduce(initial_value = 0, &proc) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/array_helper.rb', line 2 def reduce(initial_value = 0, &proc) calculated_value = initial_value self.each_with_index do |e, i| calculated_value = yield(calculated_value, e, size, i) end calculated_value end |