4. Prompting: Redux!


#1



https://www.codecademy.com/en/courses/ruby-beginner-en-0i8v1/0/4?curriculum_id=5059f8619189a5000201fbcb#


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!"
else
    puts "Error!"
end

Thanks!


#2

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

#5

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