My code goes through but wont redact


#1

My code below goes through, but wont redact. Instead of redacting, the word for redact disappears from the output- eg: Cake is ["Cake", "is", "good"]. Good is the word that supposed to redact. Can some advice please.

puts "this is the first sentence "
text = gets.chomp

puts "second test "
redact = gets.chomp

words=text.split (" ")

words.each do |words|
if words == redact
print = "REDACTED "
else
print words + " "
end
end


#2

@dara_dc
As your are using the equal-sign =
in your
print = "REDACTED "
you are assigning the string "REDACTED " to print
and thus not actually printing....


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.