On Tue, Sep 4, 2012 at 10:19 AM, Edward QU <[email protected]> wrote:
> 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?

Open the text editor, start typing...

Seriously: how would you do it on paper if you would not know
beforehand how many items there are to add?  Think about it.  Then
transcribe that algorithm to code - it's not that difficult.
Documentation of Ruby's core classes will help:

http://rdoc.info/stdlib/core/frames

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to