From: Merrie Date: 2007-04-10T01:23:18+09:00 Subject: Re: Infinate Loop - Please Advise Oh..silly me, thank you all! Merrie ----- Original Message ----- From: "John Joyce" To: "ruby-talk ML" Sent: Monday, April 09, 2007 12:18 PM Subject: Re: Infinate Loop - Please Advise > You have no looping structure. > > block of code for loop should be contained by > {...} > for one-liners, or > do ... end > for multi-line blocks. > try: > > beerno =99 > while beerno > 0 do > puts "#{beerno} bottles of beer on the wall, take one down, > pass it around," > beerno = beerno - 1 > puts "#{beerno} bottles of beer on the wall." > end > end > > of course, there are many ways to build this same looping/iterating/ > enumerating structure! > some are more rubyistic than others. > > On Apr 10, 2007, at 12:44 AM, Merrie wrote: > >> This program produces an infinate loop. I am learning from Learn to >> Program and do not have a clear example how to do this particular >> example. It is suppose to count down the bottles and repeat the >> phrase until it reach 0 bottles of beer then end :) >> >> Merrie >> ---------------------------------------------------------------------- >> --------------- >> >> beers = 99 >> beerno = beers - 1.to_i >> while beerno != 1 >> puts '99 bottles of beer on the wall, take one down, pass it >> around, there are ' + beerno.to_s + 'bottles of beer on the wall.' >> >> end > >