From: Raj Sahae Date: 2007-04-10T03:03:52+09:00 Subject: Re: Infinate Loop - Please Advise John Joyce wrote: > here's another example, using downto > > > beer = 99 > beer.downto(0) do |b| > puts "#{b} bottles of beer." > puts "take one, drink it." > puts "#{b - 1} left." > end > > but that needs an if statement to take care of the negative beer! > > beer = 99 > beer.downto(0) do |b| > puts "#{b} bottles of beer." > if b > 0 do > puts "take one, drink it." > puts "#{b - 1} left." > end > end > > > Of course it could be shorter still. but that's for you to toy with. > > why wouldn't you just have beer.downto(1) and ditch the if statement?