I have a couple of questions


#1

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

the code above is the intro to this lesson
i had a couple of questions.

  1. at the top (text=gets.chomp) does the computer automaticaly know to do this action on the answer the user gives us???

#2

Gets allows you to get a response, and chomp bites off excess space. I don't understand your question.


#3

ok. i also didnt understand line 5

words = text.split(" ")


#4

It splits it into individual characters to be checked for redacting.


#5

so line 9? does what?


#6

It sees if the word is not equal to the redacted word.


#7

sorry i meant the 10th line


#8

That prints the word with a space, so that the words aren't jumbled together.


#9

great i think i get it now. thanx!