Night at the movie - DELETE


#1

My code seems to work but it is skipping the if statement and jumping straight to the else one.

when "delete"
  puts "What movie would you like to delete?"
  title = gets.chomp
  title = title.to_sym
   if movies[title.to_sym] = nil 
   puts "This movie is not in the library!"
   else movies.delete(title.to_sym)
   puts "This movie has been deleted"
   end

I type in a movie that in not in my hash and it displayed "This movie has been deleted". I was expecting the if statement result "This movie is not in the library!"

I am missing something here?


#2

Hi here

if movies[title.to_sym] = nil

Change = to ==


#3

Thank you wizmarco.

I figured it out.
:slightly_smiling: