Getting Error : It looks like you didn't add to the movies hash


#1

Stuck at "A night at the movies" Prompting: Redux

Instructions
1.Inside your when "add" block, remove the puts "Added!" statement.
In its place, prompt the user for a movie title. Save the result in a new variable called title. (*Your code already has an example of how to do this!)
2. Next, prompt the user for the rating of the movie. Save that in a new variable called rating.
3. Add that movie/rating pair to the movies hash and puts a message indicating the pair was added. (No need for to_sym or to_i just yet!)

Below is my code -

movies=Hash.new
movies = {
"3idiots" => 5,
"dangal" => 4
}
puts "Enter movie of your choice"
choice = gets.chomp
case choice
when "add"
puts "Enter a movie title"
title = gets.chomp
puts "Enter rating of above movie"
rating = gets.chomp
movies.store(title, rating)
puts "Pair added"
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#2

I'm a little confused, you've posted an error message and instructions, but no question, just the statement that you are stuck. What do you want?

If you're wondering how you should approach this situation (then you should ask that) then you might consider whether what the error message is saying is indeed a problem, and if that is indeed happening, and then you can think about which part of the code is responsible for that behaviour and how it should look instead.
If there's any trouble along the way of doing that, then those would be questions you could ask. But not "I'm stuck"! There's no answer to that. It doesn't describe what you're looking for or what stops you!


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.