5.Not My Type

When I type in ‘add,’ it says “Error!”.
What’s going on?
Here’s my code:

movies = {
    'The Maze Runner' => 10

puts "Please select 'add', 'update', 'display', or 'delete'"
answer = gets.chomp

case movies
when "add"
   puts "What movie do you want to add?"
   title = gets.chomp
   puts "What rating do you want to have?"
   rating = gets.chomp
   title.to_sym = rating.to_i
   puts "The movie, #{title}, has a rating of #{rating}."
when "update"
  puts "Updated!"
when "display"  
  puts "Movies!"
when "delete"  
  puts "Deleted!"
  puts "Error!"

Okay. First I changed ‘case movies’ to ‘case answer’.
The code worked but it says ‘Oops, try again. Did you call .to_sym on title and .to_i on rating before adding them to the hash?’.
What did I do wrong?

I was so stupid.
I forgot to put 'movies[title.to_sym] = rating.to_i '.

I figure out how to fix it…
just type add when you submit your code… I did spend more than hour in this :confused:

1 Like

When I used update after it gave me the thumbs up, it said: *__undefined method to_sym' for nil:NilClass__* Did it just want me to useadd, or does the code formovies[title.to_sym] = rating.to_i` have a problem?

When I used update after it gave me the thumbs up, it said: undefined method `to_sym’ for nil:NilClass
Did it just want me to use add, or does the code for movies[title.to_sym] = rating.to_i have a problem?
What do you want to do? (add, update, display, delete)
What movies do you won’t to watch?
add --------> This while use add (“Superman3” => 5.5 )
What is your choice
What’s the rating?
The movie superman3 has a rating of 5.5.

This from 4/10 Prompting: Redux!

even if i type in add when i hit submit it says

Oops, try again. Make sure to test your program by choosing ‘add’.

why is it saying that even knowing i type in add?