From: Jian Lin Date: 2009-10-20T13:44:33+09:00 Subject: Re: can 35.times do |i| be decrement of "i" ? Rajinder Yadav wrote: > Jian Lin wrote: >> >> >> if 35.times can go decrement that would be nice too. >> >> thanks. > > Not sure I follow what you're asking, or why downto is not a good > solution? but > you could try this: > > irb(main):008:0> count=5 > irb(main):009:0> count.times { |n| puts count-n } 1. I don't want to create an extra variable. It is a simple loop to count down 35 times in a short program. 2. I want 35.times because it says it is 35 times, very clearly. 35.downto(1) you will need to think a little how many times it is. My purpose is to do it 35 times, so 35.times is best, but I need the count down. Something like 35.times.countdown do |i| print i, " " # do something end -- Posted via http://www.ruby-forum.com/.