0
Я попросил пользователя добавить новый рейтинг, чтобы добавить старый, но значение все равно останется прежним. Что я здесь делаю неправильно?Обновление хэш-значения с новым
movies = { the_dark_knight: 9, mrs_doubtfire: 8.5 }
puts "***** Welcome to the movie guide!! ***** "
puts "***** Enter a choice! *****"
choice = gets.chomp
case choice
when "add"
puts "Please enter the title of the movie"
title = gets.chomp
puts "Now enter your rating for this movie!"
rating = gets.chomp
if movies[title.to_sym] == nil
movies[title.to_sym] = rating.to_i
else puts "That movie already exists!"
end
when "update"
puts "Enter the title that you would like to update!"
updater = gets.chomp
if movies[updater.to_sym] == nil
puts "This movie does not exist in the database!"
else puts " Ok! What is your new rating?"
rating = gets.chomp
movies[updater] = rating.to_i
movies
end
Кажется, я забыл преобразовать программу обновления в символ здесь. Это поставило проблему! –