a.inject(0) { |count, element| element >= 0 ? count+1 : count }

At the first iteration, count is equal to the argument of inject ( = 0 )
At each iteration count is equal to the last value returned.
The block returns the same value (count) or the incremented (count+1)
if the element is >=0.

Look at

But, the Rob Biedenharn way is the "right" way to go.

a.count {|e| e > 0}

Best regards,
Abinoam Jr.

On Wed, Dec 18, 2013 at 1:12 PM, Johanna Bettina <lists / ruby-forum.com> wrote:
> Thank you so much :). That helped me! Now I understand :).
>
> --
> Posted via http://www.ruby-forum.com/.