The Zen of Ruby 17.Incase of Many Options


#1

puts "What's your favorite language?"
language = gets.chomp
case language
when language == "Ruby" then puts "Ruby is great for web apps!"
when language == "Python" then puts "Python is great for science."
when language == "JavaScript" then puts "JavaScript makes websites awesome."
when language == "HTML" then puts "HTML is what websites are made of!"
when language == "CSS" then puts "CSS makes websites pretty."
else puts "I don't know that language!"
end

I'm stuck.
what is wrong with this code?
please help!!


#2

@aryanb16,

Have a read through
http://stackoverflow.com/questions/948135/how-can-i-write-a-switch-statement-in-ruby


#3

Use this:

case language
when "Ruby" then puts "Ruby is great for web apps!"
and so on..

Doesn't need to add language == "Ruby".