5. When and Then: The Case Statement

I’m stuck and I don’t understand why.

puts “Hello there!”
greeting = gets.chomp

Add your case statement below!

case greeting
when “English” then puts “Hello!”
when “French” then puts “Bonjour!”
when “German” then puts “Guten Tag!”
when “Finnish” then puts “Haloo!”
else puts “I don’t know that language!”

I tried with default like this older topic

But It doesn’t work.

What error are you getting? Why is it not working?
I copy/pasted your code and the double quotes that you used around English, French, German and Finnish weren’t the same as the ones used around Hello, Bonjour, and so on.

I don’t understand to. I passing thru whithout answer of the problem. thanks

When and Then: the Case Statement

I got this response from your code when pressing Enter with no typed input

Hello there!

I dont know that language!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.