4. Prompting: Redux!



Oops, try again. It looks like you didn't add to the movies hash!

I don't know how to add to the movies hash. Can someone explain how to do so and how it works?

movies = {
    'Inception' => '4'
puts "What would you like to do?"

choice = gets.chomp
case choice
when "add" 
    puts "Movie title!"
    title = gets.chomp
when "update"
    puts "Rating!"
    rating = gets.chomp
when "display"
    puts "Movies!"
when "delete"
    puts "Deleted!"
    puts "Error!"



The instructions were quite straightforward

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!)

Let me just refresh your memory to add key/value pairs to a hash the syntax is very simple and for this lesson all they want you to do is add it to your movies hash,

movies[title] = rating

So the outline of the syntax is,

hash_name[key] = value


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