6/10 Error! Error!-- I can't figure out what is wrong with my code!


#1



I can't figure out what's wrong-I checked back to 1/10 and it seems right!! I have tried over and over to fix any tiny mini details I missed... Can someone tell me what is wrong with it? Thanks in advance :slight_smile:
(i might just be blind and missing an obvious error though...)

Oh, also, error message: Oops, try again. Your syntax doesn't look quite right. Feel free to peek back at the first exercise if you need help!


    movies = {
        :harry_potter => 5,
        :rogue_one => 7
    }

    puts "What do you want to do?"
    puts "Type add to add a movie and rating."
    puts "Type update to update a movie."
    puts "Type display to display all movies and ratings."
    puts "Or, type delete to delete a movie and rating."
    choice = gets.chomp

    case choice

    when "add"
      puts "What's the title of the movie?"
      title = gets.chomp
        if movies[title.to_sym].nil?
      movies[title.to_sym] = rating.to_i
      puts "What's your rating of #{title}?"
      rating = gets.chomp
      puts "The movie #{title} has been added with a rating of: #{rating}!"
      else
        puts "That movie is already added and rated! Try another."
    end
    when "update"
      puts "Updated!"
      end
    when "display"
      puts "Displayed!"
      end
    when "delete"
      puts "Deleted!"
       end
    else
      puts "Error!"
    end


#2

when does not get an end; only the if or each sort of constructs do.

when "update"
  puts "Updated!"
when "display"
  puts "Displayed!"
when "delete"
  puts "Deleted!"
else
  puts "Error!"
end

The final end closes the case.


#3

Thank you very much!
I am still getting an error message--the same one. Do you or anyone else know why?


#4

Please post you edited code and we can take another look.


#5

Oops, sorry about that! I kept and end for one of the when statements. The code has passed now. Thanks again.


#6

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