Subject: Re: Count numbers - please help
From: Joel Pearson <lists@ b f u c >
Date: Wed, 18 Dec 2013 16:35:35 +0100
References: 412785
In-reply-to: 412785
One way to do it would be to initialise a local variable outside the
loop:
count = 0
Increment it inside the loop:
a.each { |number| count+=1 if number >= 0 }
And then return the count.
--
Posted via http://www.ruby-forum.com/.