From: Rob Biedenharn Date: 2010-01-23T00:59:02+09:00 Subject: Re: Argh?! :) kEND, $end and kELSE in a simple program On Jan 22, 2010, at 10:33 AM, Jet Koten wrote: > Hi, > > I'm completely new to programming and am learning using Ruby. > > I'm trying to get this program working using only these basic commands > that are in my program: > > puts 'Say something to the virtual hard-of-hearing Grandpa:' > while true > said=gets.chomp > year = (1930+rand(51)) > counter=0 > if said=='GOODBYE' > counter+=1 > if counter==3 > break > end > end > elsif said !=said.upcase > puts 'HUH?! SAY IT LOUDER!' > counter-=1 > end > else > puts 'NO, NOT SINCE '+year.to_s+'!' > counter-=1 > end > end > I'm really stuck about getting 'him' to break after the 3 GOODBYEs > in a > row, I've written the code the best I can and now all I get are > various > combinations of kEND, $end and kELSE. I'm guessing it's some kind of > scope issue but I don't know enough to know what I don't know... you > know? :) And to explain the error from this code: -:12: syntax error, unexpected kELSIF, expecting kEND elsif said !=said.upcase ^ -:16: syntax error, unexpected kELSE, expecting $end In more human terms (don't worry, soon you'll only see the redhead): "I found a problem on line 12 when I saw 'elsif' because I was expecting something like 'end' because I was inside a 'while' block at the time. Here's the point on line 12 that I was sure I had a problem. Oh, and then on line 16 I found an 'elsif', but I just thought the file would be finished by now." -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com