6. Error! Error!


#1

Hey I’ve searched thru all of the questions but I haven’t found a reason why my code isn’t working. If you can help me out I appreciate it. The program is running but when I test it with movies that are already saved, it ends up passing the else portion and asks for the rating.

movies= {“No Country for Old Men” => “5”,
“Dreams”=> “5”}

puts "What do you like?"
choice= gets.chomp

case choice

when "add"

puts “What’s the name of the movie?”
title= gets.chomp.to_sym

if movies[title.to_sym].nil?
puts “What would you rate it”
rating= gets.chomp.to_i

movies[title.to_sym]=rating.to_i
puts "The movie #{title} has been given a rating  of #{rating}"

else
puts “That movie/rating already exists mayne”

end

when “update”
puts “Updated!”

when “Display”
puts “Movies!”

when “delete”
puts “Deleted!”

else
puts “Error!”

end


#2

Please post a link to the exercise you are on. Thanks.


#3

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