Lesson 6: error! error! help


I don't know why my code isn't working, please help!

puts "Movie base central: what can I help you with today? (Options: add a movie please!)"
choice = gets.chomp

case choice
    when "add" 
    puts "What movie would you like to add?"
    title = gets.chomp
      if movies[title.to_sym]==nil?
        puts "What rating do you give it?"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
        puts "Thank you, movie and rating added :)"
            puts "That movie already exists!"
    when "update" 
    puts "Updated!"
    when "display" 
    puts "Movies!"
    when "delete" 
    puts "Deleted!"
puts "try again!" 

i also need help understanding what nil? means? i'm totally lost on it. does it mean it returns things if nil is true? thank you for help in advance!


Hi @aasaleem92,

Please give exercise link and also state what error you are getting. Thanks!


nil? is a method. It basically asks "is this nil?" and returns true or false. If the thing is nil, it returns true. If it is not nil, it returns false.

I think you would write it more like

if movies[title.to_sym].nil?
    blah blah blah...

I know this is kind of old, and I can't help with why the code isn't working, but I thought I this might help in case someone else was curious about nil?