Prompting Redux


#1

I have tried multiple different structures of code with this exercise, read through other forum questions that are the same as I am getting and still don't understand what is missing in my code. Can some assist me?

movies={
Star_Trek: 8, Star_Wars: 10
}
puts "What movie do you want to rate?"
choice=gets.chomp
case choice
when "add"
movies = Hash.new("Title", "Rating")
title=gets.chomp.to_sym{}
puts "What's the rating according to you?:"
rating=gets.chomp.to_i{}
if movies[title].nil? then true
movies[title] = rating
else
puts "This movie exists in our hash, so it will not be added."
end
when "update"
puts "Updated"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end

I am getting the message below.
"It looks like you didn't add to the movies hash!"

Any assistance would be greatly appreciated.


#2

Have you checked it against the instructions?


#3

Hi, I did and this is another variation of my changes. I'm not sure what I am missing.

movies={
Star_Trek: 8, Star_Wars: 10
}
puts "What movie do you want to rate?"
choice=gets.chomp
case choice
when "add"
movies = Hash.new("Title", "Rating")
title=gets.chomp.to_sym{}
if movies[title].nil? then true
movies[title] = rating
else
puts "What is a movie title?"
choice=gets.chomp
puts "What's the rating?:"
rating=gets.chomp.to_i{}
end
when "update"
puts "Updated"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#4

This is the message I am getting and I'm getting stuck on.

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


#5

For best results, follow the instructions as closely as possible. The lesson checker is quite narrowly focused.

The first input should be a command, 'add', 'update', 'display' or 'delete'.

The above line is not called for, and actually wipes out your main hash (assuming it does not raise an error).


#6

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