5/6 Redacted


#1

Hello, could someone please explain to me where second END comes from and what exactly it closes?

puts "Enter text: "
text= gets.chomp
puts "Enter a word to redact: "
redact = gets.chomp

words = text.split(" ")
words.each do |word|
    if word == redact
print "REDACTED "
else 
    print word + " "
end
end

#2

The first end closes the if statement and the second end closes the .each statement


#3

Did you get an error message "Can't convert string into an array" ?
It let me pass but I got an error


#4

Always indent your code. After indenting your code like this:

puts "Enter text: "
text= gets.chomp
puts "Enter a word to redact: "
redact = gets.chomp

words = text.split(" ")
words.each do |word|
    if word == redact
        print "REDACTED "
    else 
        print word + " "
    end
end

it's clear which blocks are requiring the end keyword.

@maxtrinh ajaxcoder's code doesn't generate any error. In case it's about your code, please post it as a new topic in apt. category and it should get resolved. Thanks! :slightly_smiling: