Prompting : Redux


#1

Where am I doing it wrong?

It always sends me this error : > Oops, try again. It looks like you didn't add Lil christmas to the movies hash! :confused:

movies = {
The_Illusionist: 4
}

puts "What would you like to do?"
puts "-- Type 'add' to add a movie!"
puts "-- Type 'update' to update a movie!"
puts "-- Type 'delete' to delete a movie!"
puts "-- Type 'display' to display movies with ratings!"

choice = gets.chomp.downcase

case choice
when "add"
    print "What movie would you like to add?"
    title = gets.chomp
    if movies[title.to_sym].nil?
        print "What's the rating of the movie?"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
        puts "#{title} has been added with a rating of #{rating}!"
    end

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

#2

Do the instructions ask us to add it manually to the hash, or as an input?

"Lil christmas" => 2,

#4

Gotta add it on input.


#5

SOLVED!

It seems like in this exercise I didn't have to convert the title to symbol like this [title.to_sym] therefore after deleting the "to_sym" it all worked just fine, thanks.


#6

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