For loop decrementing?

the incrementing for loop :

for i in 0…100
p i
end

gets 0 …> 100

is their a syntax for a decrementing one like :

for i in 100…0 (specifing the step to -1)
p i
end

100.downto(0) { |i|
p i
}

jogloran [email protected] wrote:

100.downto(0) { |i|
p i
}

thanks a lot !!!

Plug! http://code.eachmapinject.com/for_.rb
:slight_smile:

j`ey
http://www.eachmapinject.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs