# Sums up the elements in the array def sum my_array.inject(0){|total,item| total + item} end