6/10, Can't figure out what's wrong!


<Below this line, add a link to the EXACT exercise that you are stuck at.>
Hi, I’m havong trouble figuring out what’s wrong with my code.
This is my code,

movies = {
  Starwars: 4,
  Startrek: 3.5,
  Star_Kingdom: 2.8

puts "Please type what you'd like to do today:"
choice = gets.chomp.downcase
case choice
when "add"
  puts "Which movie would you like to add?"
  title = gets.chomp
  if movies[title.to_sym]nil?
    puts "What rating would you like to give to #{title}?"
    rating = gets.chomp
    title = title.to_sym
    rating= rating.to_i
    puts "The movie #{title} was added with a rating of #{rating}!
Thank You!"
    puts "The movie #{title} already is in our database!"

  when "update"
    puts "Updated!"
  when "display"
    puts "Movies!"
  when "delete"
    puts "Deleted!"
    puts "Error!"

<In what way does your code behave incorrectly? Include ALL error messages.>

I’m getting this error message:

(ruby):12: syntax error, unexpected tFID, expecting keyword_then or ';' or '\n'
(ruby):25: syntax error, unexpected keyword_when, expecting end-of-input
  when "update"

Thank You!


Missing dot before nil method.

These lines can be combined…

rating = gets.chomp
movies[title.to_sym] = rating.to_i

although your code works fine. It’s just nicer to reduce verbosity when it improves readability.


Thanks a lot! I kept on typing it in and the color didn’t change, and I just didn’t realize what was wrong with that. Thank you!
I thought so about the combination, but I wanted to be safe…


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