Hey guys,
First time posting. Nice to meet you all!
I’m attempting question 9/10 and seem to continuously get an error.
movies = {
Parkland: 5,
MI: 4,
BG: 8,
}
puts "What do you want to do?"
puts "---Add a movie?"
puts "---Update a rating"
puts "---View to view all movies."
puts "---delete to delete a movie"
choice = gets.chomp.downcase
case choice
when "add"
puts "What is the name of the movie?"
title = gets.chomp.to_sym
if movies[title.to_sym] == nil
puts "what rating do you give #{title}?"
rating = gets.chomp.to_i
movies[title] = rating
puts "You have given #{title} a rating of #{rating}."
else
puts "That movie already exists!"
end
when "update"
puts "Which movie do you wish to update?"
title = gets.chomp.to_sym.downcase
if movies[title.to_sym] == nil
puts "I don't think we have #{title} in our database."
else
puts "What rating do you wish to update #{title} with?"
rating = gets.chomp.to_int
movies[title] = rating
end
when "view"
movies.each do |movie, rating| puts "#{movie}: #{rating}"
end
when "delete"
puts "Which movie would you like to delete?"
title = gets.chomp.to_sym.downcase
if movies(title.to_sym) == nil
puts "I don't think we have that in our database."
else
movies.delete(title)
puts "Deleted!"
end
else
puts "Error!"
end
The error reads:
undefined method `movies' for #<Context:0x66fd78>
I would greatly appreciate your help!