Need some assistance with, "Control Flow Know-How"


Control Flow Know-How

Getting the error message, "can't convert String into Array"

Any help is much appreciated.

puts "Type some text here."
text = gets.chomp

puts "What do you want redacted?"
redact = gets.chomp

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


Your problem is right here,

Your words variable is what you are inside of. Words is text.split(" "). But what do you want to print if a word isn't equal to your redact variable? You want to print the word inside of the string the user gave you. You already set up the do each loop for your list words, but you want to print the word inside of words if it's not the word you want to redact. :slight_smile: Hint: You want to remove the 's' on the end of words in this specific else statement.


Thank you :grinning:


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