get total of values in array

is there an easy way to add all thevalues stored in an array together?

i tried total = @array.total but i dont think thats right?

thanks for any help

total = @array.inject(0) { |sum, value| sum + value }

The inject method comes from the Enumerable module, which Array includes. Docs are here: http://ruby-doc.org/core/classes/Enumerable.html#M003160 .

Regards, Craig