From: John Joyce Date: 2007-04-10T03:17:33+09:00 Subject: Re: Infinate Loop - Please Advise On Apr 10, 2007, at 3:03 AM, Raj Sahae wrote: > 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? I did, a few moments later. doing that stuff in irb isn't always as easy as doing it in TextMate (note to self). I like irb because I can just ask objects questions. But irb needs more flexibility (the ability to step into and out of writing a block to check something else, that would be useful) Access to all the running stuff and ability to change it while running. Oh. self.assend_to_heaven >