[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10
I\'m looking at this code but my brain is not registering how the number 1
is equivalent to the following:
def my_function(r, e) r+e end a = [1, 2, 3, 4] result = 0 a.each do |value| result = my_function(result, value) end