A Night at The Movies (Prompting Redux!)



Hi! Would appreciate it if someone can help explain what is wrong with my code. I looked at all the explanation provided in the forum but non seemed to work. I kept getting this "Oops, try again. Did you create a variable called title?".

movies = {
Curious_Case_of_Benjamin_Button: 5,
Dark_Knight: 5,
Spiderman: 4

puts "What do you want to do (add, update, display or delete)?"
choice = gets.chomp

case choice
when "add"
puts "What is the movie title?"
movie_title = gets.chomp
puts "What is the rating of the movie?"
movie_rating = gets.chomp
movies = Hash.new
movies[movie_title] = movie_rating
puts "The movie #{movie_title} has a rating of #{movie_rating}."
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
puts "Error!"


Did you try with just title?

title = gets.chomp

  1. movies = Hash.new("movie_title" => movie_rating) and
  2. Remove: movies[movie_title] = movie_rating - this works


Remove: movies = Hash.new and
Convert movies[movies_title] to movies["movies_title"] - not sure if this works but you can try