5/20 When and Then: The Case Statement

I don’t know but this code isn’t working
puts “Hello there!”
greeting = gets.chomp
case greeting
when ‘English’ then puts “Hello!”
when ‘French’ then puts “Bonjour!”
when ‘German’ then puts “Guten Tag!”
when ‘Finish’ then puts “Haloo!”
else “I don’t know that language!”

It says Oops, try again. It looks like your program doesn’t default to printing ‘I don’t know that language!’
I even tried to copy paste the code but no use

Instead of “else” try “default”

I didn’t know default works in ruby as well,
useful info. Thanks for that lolman

BTW I found what the error was I forgot the ‘puts’ after the else. Lams
So instead of else “I don’t know that language!”
it should be: else puts “I don’t know that language!”

Oh, I didn’t even see that, good catch!

So, other than adding “puts”, the only mistake was “default” instead of else? I don’t get it? Why doesn’t “else” work?

default is not a Ruby reserved word. To see this proved out, got to this module’s first lesson and change,

  puts "Sorry, I didn't understand you."


  puts "Sorry, I didn't understand you."

and Submit. Then enter a command that is not in the list:

What would you like to do?
-- Type 'add' to add a movie.
-- Type 'update' to update a movie.
-- Type 'display' to display all movies.
-- Type 'delete' to delete a movie.

Now change it back to else.

Sorry, I didn't understand you.

2 posts were split to a new topic: Seems like there might be a bug here