It looks like you didn't add to the movies hash: bug?


#1

I have tried my solution and I have tried nearly every other solution I could find online from a variety of sources. It keeps telling me I have not added to the movies hash. WHY?

movies = {'FavoriteMovie' => 10}
puts "some random ■■■■"
choice = gets.chomp

case choice
when "add"
puts "What is the title?"
title = gets.chomp
puts "And how would you rate it? 1 to 4."
rating = gets.chomp
movies[title] = rating
puts "Added #{title} with a rating of #{rating}"
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end

How do I get past this checkpoint? also, I would have skipped it but the next two checkpoints do not pass, even when I use suggested solutions other than mine which apparently passed for someone else online. How do I know if this is a bug with the platform as opposed to my code?


#2

I've spent some time trying to get your code to fail in my browser and the only thing I have experienced that could cause the error is the following:

  • when I'm prompted to add a movie in the black box in the top right corner of the screen with "some random ■■■■", I enter anything apart from "add" - this will cause the error. If you enter "add", it should then allow you to enter a title and a rating.

Hopefully this helps! If this isn't the problem, then I'm not sure what could be causing this.


#3

Thank you for checking! I tried using different browsers but still it tells me I'm not adding to the movies hash.

I rewrote it as follows and still a no go :frowning:

movies = {'FavoriteMovie' => 10}
print "movie?"
choice = gets.chomp

case choice
when "add"
puts "movie title?"
title = gets.chomp
puts "rating?"
rating = gets.chomp

    movies[title] = rating
    puts "movie has been added"
when "update"
    puts "Updated!"

when "display"
    puts "Movies!"
when "delete"
    puts "Deleted!"
else
    puts "Error!"

end

Anyone? How do I report a bug if that is what it is?


#4

Figured it out! Very embarrassing :confused: I'll confess in case another newbie to coding has the same issue. The problem was, when I was running tests in their console, I wasn't using the actual keywords. The whole course I have gotten away with adding "sngrlkrjgs" or whatever random numbers on the keyboard. Just to see if it would work. That is all good except when testing a case statement, naturally. I wasn't using the actual keywords for testing and it just never crossed my mind since all the testing was open ended prior to this checkpoint.


#5

@fairbco I thought this might be the probelm. Apologies for not explaining it very well!

No need to be embarassed - I'm sure this will be helpful for a lot of people in the future :+1: It's great that you got that fixed, and can move on now!


#6

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