Marcelo
5/5/2009 8:07:00 PM
On Tue, May 5, 2009 at 13:46, Taylor Lodge <ubermouse@live.com> wrote:
> After more fiddling i fixed the error (needed another end for the if
> statement DUH) and it works but I can't figure out sum if you do sum +=
> nums it gives an error.
It's easier for people to help you if you show the error you are seeing.
In this particular case, since you are not initializing sum, the first
time the program encounters:
sum += num
you are effectively doing:
sum = nil + num
Something like this:
> nums = Array.new(8) { rand(10000) }
> max = 0
> min = 10001
sum = 0
Also, in this case it's irrelevant, but you might wish to initialize
min and max like this instead:
min = max = nums[0]
Marcelo