Code Flow Know How problem


I cannot for the life of me figure out what is wrong with my code, even after reading through the other topics. Please help?

puts "Text here"
text = gets.chomp
puts "Word to redact"
redact = gets.chomp
words = text.split(" ")
words.each do |word|
if word == taylor
print "REDACTED "
print word + " "


if word == redact


how does ruby go from words to word ?
ie, word**s** = text.split(" ")
why do we not use if words == redact ? How do we know when to remove the s from our variable?


words is defined in the program as a list. The object has an .each method which is given a block to execute on the iterable. word is the locally defined block parameter. We write this. Ruby only takes what we write. It knows it's a placeholder variable for the individual values in the list because of where we have written it.

Baically, we could use any name we wish for this purpose, even a letter or an underscore. Once the iteration is completed the block is terminated and the variable is erased from memory.