6/10. Error! Error! Else not executing



my code for the exercise is as follow:

movies = {
the_third_man: 10

puts "What would you like to do? "

choice = gets.chomp

case choice
when "add"
puts "What movie would you like to add? "
title = gets.chomp
if movies[title.to_sym].nil?
puts "What rating does the movie have? "
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "The movie #{title} has been added with the rating of #{rating}"
puts "You have already rated this movie!"
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
puts "Error!"

When I enter the exact same title in the console, it doesn’t print out the “You have already rated this movie!” statement, but it prompt me with the rating question.
I can go through with the lesson, but I can’t figure out what’s wrong with my code. I’ve already found the same issue raised by others, but answers given didn’t make much sense to me.




Link to the exercise, please? Also a screenshot or error message could be useful for us.


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