puts "Text to search through: " text = gets.chomp puts "Word to redact: " redact = gets.chomp words = text.split(" ") words.each do |word| if word != redact print word + " " else print "REDACTED " end end
Hello, why does the Ruby console print an array at the end of the looping ? As I know, Ruby console prints the last statement and the
words variable is not at the last statement. Why ?
Text to search through:
Word to redact:
billy REDACTED ["billy", "halim"]