Subtraction question

swaraj dhumne wrote in post #1048821:

anyways, I have a question : how would one subtract a list of numbers in
a row?

What have you tried so far? Is this a homework question?

I suggest you start with putting the numbers in an array:

a = [1, 7, 3, 5, 9]

Then take the first element as the initial sum, and make a loop which
iterates over the remaining elements, subtracting them from the sum.

To get all elements apart from the first, use a[1..-1]

There are much more concise ways of doing this in Ruby, but you should
start with the simplest way, using whatever language constructs you
know. Then you can come back and ask if there is a neater way.

ยทยทยท

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