Sum of Array
Sum of Array
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Compute the sum of the elements of an Array
Ruby
ary = [1,2,3,4,5] sum = ary.inject{|currentSum,element|currentSum+element}