From: Rob Biedenharn Date: 2010-01-23T03:28:19+09:00 Subject: Re: Argh?! :) kEND, $end and kELSE in a simple program On Jan 22, 2010, at 12:43 PM, Jet Koten wrote: > And for everyone's reference, my code now looks like this: > > puts 'Say something to the virtual hard-of-hearing Grandpa:' > counter=0 > while true > said=gets.chomp > year = (1930+rand(51)) > if said=='GOODBYE' > counter+=1 > if counter==3 > break > end > elsif said !=said.upcase > puts 'HUH?! SAY IT LOUDER!' > counter-=1 > else > puts 'NO, NOT SINCE '+year.to_s+'!' > counter-=1 > end > end > > and the problem with it is that it doesn't break after getting GOODBYE > three times in a row... > -- > Posted via http://www.ruby-forum.com/. > But it probably eventually hits the break if you keep saying "GOODBYE" Either run the debugger or add a line right after the while true puts "the counter is #{counter}" Then it should become clear. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com