Error - you didnt add to movie hash


#1

Hi,

My code for the exercise 4 does not seem to work.

Below this line, add a link to the exercise that I am stuck at.

Errors saying I did not add to movie hash keep prompting. Pls advice.


Replace this line with your code. 
movies = {
    Blue:5,
    Red:3,
    Black:2,
}
puts "Which movie do you like"
choice = gets.chomp

case choice
when "add"
    puts "Movie title"
    title = gets.chomp
    if movies[title.to_sym].nil?
    puts "Movie rating" 
    rating = gets.chomp
    movies[title.to_sym] = rating.to_i
    puts "#{title} has been added with a rating of #{rating}!"
else
    puts "Movie already added"
end

when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
    puts "Error!"
end


#2

What have you done to solve this?

Have you investigated whether it was added?
What did you add? What should have been added?
To what should you add?
What types should all those things have?
Have you read over the instructions and checked that you did each and every thing said?
..and so on


#3

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