# Sum & Product of an Array 1.0

OS : Windows / Linux / Mac OS

Script Licensing : Other Free / Open Source License

Created : Jun 9, 2007

Downloads : 10

Thank you for voting...

## How to sum all the numbers in an array, or get the ...

How to sum all the numbers in an array, or get the multiplication product of the same numbers, without resorting to an ugly for loop?

Ruby’ s inject to the rescue; this snippet extends the array class with the methods sum and product, which can hereafter be used on any array in Ruby. Note that the parameter to inject is the initial value of s, the result, and thus obviously different depending on whether we’ re doing addition or multiplication.

Ruby’ s inject to the rescue; this snippet extends the array class with the methods sum and product, which can hereafter be used on any array in Ruby. Note that the parameter to inject is the initial value of s, the result, and thus obviously different depending on whether we’ re doing addition or multiplication.

**Sum & Product of an Array 1.0 scripting tags:**array, sum array, initial, product, inject, multiplication, parameter, product array, sum product array, numbers, ruby sum.

**What is new in Sum & Product of an Array 1.0 software script?**- Unable to find Sum & Product of an Array 1.0 news.

**What is improvements are expecting?**Newly-made Sum & Product of an Array 1.1 will be downloaded from here. You may download directly. Please write the reviews of the Sum & Product of an Array. License limitations are unspecified.