Hi, I'm new here and having some trouble with the Update lesson.

Instructions: "Inside your when "update" block, remove the puts "Updated!" statement.
Prompt the user for a movie title. Store it in title.
if the movies[title] is nil, then the movie is not in the hash. Please puts a string telling the user of their error.
Otherwise (else), we need to update "

The Error message I have been receiving: "Make sure to test your program by choosing 'update"
The first time around I didn't choose update the second and third I did but still get this message.

Here's the code:

movies = {
   Amelie: 4
puts "what would you like to do?"
choice = gets.chomp
choice = case
when "add"
puts "what is the title?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "what is the rating?"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "#{title} has been added with a rating of #{rating}."
    puts "That movie already exists! Its rating is #{movies[title.to_sym]}."
when "update"
puts "What movie do you want to update?"
if movies[title.to_sym].nil?
    puts "Movie not found!"
    puts "What's the new rating? (Type a number 0 to 4.)"
    rating = gets.chomp
    movies[title.to_sym] = rating.to_i
    puts "#{title}has been updated with new rating of #{rating}."
when "display"
puts "Movies!"
when "delete"
puts "Deleted"
    puts "Error!"


'case' is not a variable, but a keyword.

case choice


Thanks for the response! I changed it and still getting the same error message.


Could it be the missing space character after the string interpolation?

"#{title} has been ... "


I thought so too but no. Thanks, I'm just going to look carefully over everything again.


It worked. I think it was what I was typing. I obviously needed to type a movie already in the hash. (might want to step away from the computer and breathe :slight_smile: )


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