I7/20 help

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

Hi I’m stuck on this topic please help.
<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/ruby-beginner-en-1o8Mb/3/3?curriculum_id=5059f8619189a5000201fbcb#
<In what way does your code behave incorrectly? Include ALL error messages.>
I keep getting these error messages.
(ruby):15: unterminated string meets end of file
(ruby):15: syntax error, unexpected $end, expecting keyword_end

```puts "What's your favorite language?" language = gets.chomp

case language
when language = “Ruby”
puts “Ruby is great for web apps!”
when language = “Python”
puts “Python is great for science.”
when language = “JavaScript”
puts “JavaScript makes websites awesome.”
when language = “HTML”
puts “HTML is what websites are made of!”
when language = “CSS”
puts “CSS makes websites pretty.”
else
puts "I don’t know that language!
end

Replace this line with your code.

<do not remove the three backticks above>

@slasher2468,
With

language = "Ruby"

you are using the assigment operator =
you assign the string Value “Ruby” to the variable language

But in your when-clause you should use a comparison operator ===
you want to compare the referenced-Value of variable language to a string Value

http://stackoverflow.com/questions/3154876/ruby-comparison-operators-vs

I changed it to this but it still doesn’t work.

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```

@slasher2468,
Your case-when-else-end syntax is incorrect…
Have a read
http://stackoverflow.com/questions/948135/how-can-i-write-a-switch-statement-in-ruby?rq=1

I read that but I still can’t get my code to work.

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

@slasher2468,
The syntax for a CASE WHEN ELSE END statement
As case you present a value
as when you present a value which will be compared with the case-value
( internally the === comparison operator )

##==== Example 1. ======

test="ok"
case test
when "ok"
  puts "it is ok"
else
  puts "don't know"
end

##==== Example 2. ======

test='ok'
case true
when test === "ok"
  puts "2nd it is ok"
else
  puts "2nd don't know"
end

also watch your quotes at the bottom. if you put that in verbatim, you’ll have a pretty easy to fix error but its still important to note

I passed it with this code but it only worked if i put an unknown coding language
here is my code: 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

@slasher2468
For instance if you
enter the language “Ruby”

language == "Ruby"

this expression will result in a Boolean true

Then
The comparison is done by comparing

  • the object in the when-clause ( which is the Boolean true )
  • with the object in the case-clause _( which is the =string=Value “Ruby”
    using the === operator.

Please READ !!!
I7/20 help
and
http://stackoverflow.com/questions/948135/how-can-i-write-a-switch-statement-in-ruby?rq=1

1 Like

yup! remove the
when language == "Ruby"
bit, and replacing it with
when "Ruby"
will cause it to work. read what leonhard posted. Its good information

puts “I don’t know that language!

just put a comma at the end