我找不到错误,它一直告诉我:哎呀,再试一次。看起来你没有添加到电影哈希! 谢谢。
movies = { 'himym' => 5,
'oitnb' => 4 }
puts "Which one do you like better?"
choice = gets.chomp
case choice
when "add"
puts "What is your favorite movie?"
title = gets.chomp
puts "What would you rate it?"
rating = gets.chomp
movies = {}
movies[title] = rating
puts "#{title} with rating #{rating} has been added!"
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end
答案 0 :(得分:1)
我测试了你的代码 - 我陷入了同样的困境。 CodeAcademy的说明并不总是很清楚。你的代码,根据CA的要求是对的,你只需要写“添加”作为“你更喜欢哪一个?”的答案。在CA的虚拟机上测试代码时。所以:
choice = "add"
这样你就会在过滤时运行你的情况/。得到它了?