6.5 Exercise


#1

Guys I need help, I've been stuck here for a few hours.
It keeps giving me an error :smile: undefined local variable or method `movie' for #
also saying that I did not choose add when I actually did.
Thanks for the help.

movies = {
 Batman: 4,
 Titanic: 4,
 BraveHeart: 5
}

puts " what would you like to do?"
choice = gets.chomp

case choice 
when "add" 
    puts "which movie do you want to add?"
    title = gets.chomp.
    if movie[title.to_sym].nil? 
        puts "What rating will you give it? (pick number 1-5)"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
when "update" 
    puts "Updated!"
when "display" 
    puts "Movies!" 
when "delete"
    puts "Deleted!"
else
    puts "Error"
    end

Instructions
Call .to_sym on your title and .to_i on your rating so that your movie titles are stored as symbols in the hash and the associated ratings are stored as integers.


#2

There is your culprit. Should be movies.

You could also complete the add case with,

        puts "Added!"