Redact 5/6 - Says I passed but doesn't actually redact anything


Control Flow Know How

I get no error messages. It tells me great job. But when I run the code, it doesn't redact anything.

puts "insert text"
text = gets.chomp
puts "please redact"
redact = gets.chomp

words = text.split (",")

words.each do |word|
    if word == redact
    print "REDACTED "
    print word + " "


The text is not likely to contain any commas. Use a space character as the separator to split on.


I just ran it with the comma and without the comma, they both worked for me. You are probably seeing the interpreter echoing. Something like this,

=> ["Joey"]

The second line is just showing you what you inputted. (VERY confidential if I say so myself!)


'the difference was the comma in the text.split. Works totally fine, now.
Thank you!


Quite, indeed! I see what you're saying, but even in the final line, it wasn't showing REDACTED at all. The clincher turned out to be the comma in the text.split.

Many thanks


You should hit the check-mark box at the bottom of MTF's post to mark that he fixed the problem. :+1:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.