On 01/29/2014 06:25 PM, Coralie Harmache wrote:
> Hi! This is the 'Deaf Grandma' exercise from Chris Pine's Learn to
> Program Second Edition book in which there is an instruction to make a
> program that what is said to grandma is not heard unless it is in
> capital letters.
> In the extended version of this exercise when you should BYE three times
> in a row she finally lets you leave.
>
> Im having trouble understanding the error messages Ruby is giving me
> namely:
>

This error messages are cryptic almost always indicate you have 
misplaced an "else" and an "end" somewhere.

> deaf.rb:13: syntax error, unexpected kELSE, expecting kEND
>    else input == input.upcase
>        ^

This means Ruby was expecting to see an "end" keyword (kEND), but 
instead got "else". In other words, you have an "else" keyword where it 
shouldn't be.

> deaf.rb:17: syntax error, unexpected kELSE, expecting $end
> else input == 'BYE'
>      ^

Similarly, Ruby was expecting the end of the file ($end) but instead got 
another "else" keyword.

>
>
> Here is my code:
>
>
> /Deaf Grandma/
>
>
> while input != 'BYE'
>    puts 'Say hello to your grandmother'
>    input = gets.chomp
>
> if input == input.downcase
>      puts 'HUH?! SPEAK UP, SONNY!'
>    end
>
>    else input == input.upcase
>      puts ('NO, NOT SINCE' + (rand(21)+1930).to_s + '!')
>    end
>
> else input == 'BYE'
>    break
> end
>
>
> Thank you
> Coralie
>

In Ruby if/else looks like this:

if some_condition
   do_some_stuff
else
   do_some_other_stuff
end

Compare this to your code.

-Justin