David - Musings of an SRE

Sum up array contents with a simple method

With just:

array.inject(:+)

It will take an array and sum it up.

>> [0,2,3,1]
>> [0,2,3,1].inject(:+)
=> 6