Delete! omg so frustrating


#1

What is the syntactical difference between these two blocks? My version is the first block, and codecademy's is the second. My version will not work in any environment, and I can't figure out why. Please help! I keep getting a tFID error, and I don't know what that means.

when 'delete'
puts "What movie would you like to delete from the list?"
title = gets.chomp
if movies[title.to_sym]nil?
puts "This movie is not in our list."
else
movies.delete(title.to_sym)
puts "The movie #{title} has been removed from the list."
end
else
puts "Sorry, I didn't understand you."
end

when 'delete'
puts "What movie do you want to delete?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "Movie not found!"
else
movies.delete(title.to_sym)
puts "#{title} has been removed."
end
else
puts "Sorry, I didn't understand you."
end


#2

Is this something you are looking for?


#3

Yeah. If the title isn't in the hash

puts "Movie not found"

The only difference I can see is the strings, the syntax is exactly the same, except the second block will run, and the first gets the tFID error.


#4

Holy cow!
my statement has

movies[title.to_sym]nil?

it should be

movies[title.to_sym].nil?

I MISSED THE '.' before nil?

Well there ya go.