Redacted 4/6


#1

Hello,
I am doing exercise 4 in “Redacted” section,
and I think my code seems right, but the error message keeps popping up:

puts "Write something: "
text = gets.chomp
puts "Write something you want to be detected: "
redact = gets.chomp

words = text.split(" ")

words.each do |word|
  print words + " "
end

Can anybody tell me what I am doing wrong here?
Thank you.


#2

here:

print words + " "

you print words (which is an array) and try to concat it with a string.


#3

So do you mean I can’t concat array with a string?
So I need to delete the last part which is

  • " " ?

#4

yep, but this indicate you focus on the wrong thing

what is the purpose of the loop? To get the elements (strings) from array, but then inside the loop, use the strings, not the array.


#5

I got it now,
Thank you!!


#6