Edward QU wrote in post #1074559:
> dear all
>
> a_array=[2,4,6,8,10]
> I want to sum the elements of the array:
> 2+4+6+8+10
> how to write the script?
>
> many thanks!
> best regards
> Edward

Hi Edward,

You could also use the inject method from the Enumerable module like
this:

  array.inject(0) { |sum, i| sum+i }

Cheers.

-- 
Posted via http://www.ruby-forum.com/.