Update not updating


#1

So my code runs, but codecademy says its not and it is really confusing any and all help appreciated.

movies = {
"the amazing spiderman".to_sym => 5
}

puts "What would you like to do?"
puts "--- Add"
puts "--- Update"
puts "--- Display"
puts "--- Delete"
choice = gets.chomp.downcase

case choice
when "add"
puts "Give a title please."
title = gets.chomp.to_sym.downcase
if title == movies[title].nil?
puts "Now a rating."
rating = gets.chomp.to_i
movies[title] = rating.
puts "The movie has been added!"
else
puts "I already have that movie in my database."
end
when "update"
puts "What movie would you like to update?"
title = gets.chomp.downcase
if title == movies[title].nil?
puts "That movie is not in my database!"
else
puts "What would you like to change your rating to?"
rating = gets.chomp.to_i
movies[title] = rating
puts "Your rating has been changed."
end
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#2

Never mind I just needed to turn the gets.chomp.downcase into gets.chomp.to_sym.downcase


#3

When I enter my code, it always puts the if statement, and never, runs else for some reason:


when "update"
  puts "Movie title? "
  title = gets.chomp
  if movies[title].nil?
    puts "You've made a mistake"
  else
    puts "What rating does it have?: "
    rating = gets.chomp
  end

What could be the problem?


#4

i have the same problem help