Saving a String as a Variable?


#1


How might you make a new redacted string and save it as a variable, rather than just printing it to the console?

Has anyone solved this for themselves?


Replace this line with your code.


#2

One way would be to built a list then return it as a string..

    words.each do |word|
        result = []
        if word != redact
            result.append(word)
        else
            result.append("REDACTED ")
        end
    end
    return result.join(' ')

#3

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