Night at the movie - DELETE


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"

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?


Hi here

if movies[title.to_sym] = nil

Change = to ==


Thank you wizmarco.

I figured it out.