I tried to replace any input got from "Redact!", regardless of their case, with my code. What I´m getting is quite unexpected. If I write, for example, "ZOOMBY" and "zoomby" and I ask it to replace "ZOOMBY", the one that gets replaced is the downcase one.
In the example below, I replaced two words: "ZOOMBY" and "name".
Write something, please
Hi, I´m ZOOMBY, zoomby is my name
Hi, I´m ZOOMBY, REDACTED is my REDACTED
Why is that happening? When using
if redacts.include? word.downcase ain´t I asking to change both, upper and down case?
puts "Write something, please" text = gets.chomp puts "Redact!" redact = gets.chomp.downcase words = text.split (" ") text = "" redacts = redact.split (" ") redacted_sentence = "" words.each do |word| if redacts.include? word.downcase redacted_sentence += "REDACTED " else redacted_sentence += word + " " end end puts redacted_sentence