On Sat, 1 Apr 2006 02:08:40 +0900, "Bill Guindon" <agorilla / gmail.com> wrote: >On 3/29/06, Jan_K <non / none.com> wrote: >[snip] >> I can't use "Until" because it wasn't covered in the book so far (even >> though it seems pretty straightforward what it does). Ditto for "+-" >> >> What was covered so far up until this chapter: >> >> if, else, elsif, while >> > >Here's a very simplified example that I believe uses only what's been >covered up to that point. > >last_input = '' >goodbye = 1 > >while goodbye < 3 > input = gets.chomp > > if input == input.upcase > puts "NO, NOT SINCE " + (1930 + rand(21)).to_s > else > puts "HUH?! SPEAK UP, SONNY!" > end > > if input == 'BYE' and last_input == 'BYE' > goodbye = goodbye + 1 > else > goodbye = 1 > end > > last_input = input >end I'm not really understanding what last_input is exactly doing. Looks like nothing. This works without any problems: goodbye = 1 while goodbye < 4 input = gets.chomp if input == input.upcase puts "NO, NOT SINCE " + (1930 + rand(21)).to_s else puts "HUH?! SPEAK UP, SONNY!" end if input == 'BYE' goodbye = goodbye + 1 else goodbye = 1 end end