With just: array.inject(:+) It will take an array and sum it up. >> [0,2,3,1] >> [0,2,3,1].inject(:+) => 6