J
Jian Lin
if there is a loop
35.times do |i|
print i
# do something here...
end
it is nice except i hope to count down the "i"...
it can be
print 35 - i
but then if the number needs to be 36 then i need to change both places.
or it can be
35.downto(1) do |i|
but doing so feel like needing to do some counting... 1 to 35 is in fact
35 times... so that's good
if 35.times can go decrement that would be nice too.
thanks.
35.times do |i|
print i
# do something here...
end
it is nice except i hope to count down the "i"...
it can be
print 35 - i
but then if the number needs to be 36 then i need to change both places.
or it can be
35.downto(1) do |i|
but doing so feel like needing to do some counting... 1 to 35 is in fact
35 times... so that's good
if 35.times can go decrement that would be nice too.
thanks.