Redacted 5/6


Can someone explain why this code is incorrect?

puts "Text to search through"
text = gets.chomp
puts "Word to redact"
redact = gets.chomp

words = text.split(" ")

words.each { |word| print word}
if word == redact
print "REDACTED "
print word + " "

I am getting an undefined local or method 'word' error on this one. Haven't I declared that particular variable in my .each function call?

Any help is appreciated. Thanks!


I think you need to remove 'print word' from the 'words.each' line. So that line should read "words.each { |word|}"