Undefined local variable or method `word' for #<Context:0xb331c0>


#1

puts "1st input"

text = gets.chomp

words = text.split (" ")

puts "2nd input"

redact = gets.chomp

words.each {|word|}

if word == redact
print "REDACTED"
else
print word + " "
end


#2

You're doing nothing in your each block.

The problem you're having is that since your if/else is outside of your block, word is considered a new variable with no value yet (hence the undefined error) when you make the comparison.

Try inserting your if/else inside your each block.