5. When and Then: The Case Statement


#1

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!"
end

I tried with default like this older topic


But It doesn’t work.
Thanks


#2

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.


#3

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


#4

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!

#5

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