Redacted #5 - I don't understand why this is working


#1

I do not understand how this code is working, let alone how it passed. My word wasn't actually redacted...
Can someone explain it to me?


puts "Enter some text: "
test = gets.chomp

puts "What to redact: "
redact = gets.chomp

words = test.split("")

words.each do |word|
    if word != redact
        print word + ' '
    else
        print "REDACTED"
    end
end


#2

All kinds of stuff passes that the hard and fast rulebooks say should not. But, fortunately we're not of the hard and fast. Lesson checkers can be finacky, especially if not completely thought out. Bear in mind that these early couses were largely written by members. They were not paid staff, to begin with. They just wrote usable courseware. CC engineers took one crack at fixing things and shut down the editor. Things are what they are now. As long as a learner can get past a lesson, there is nothing holding them back. Correct code also passes, albeit.


#3

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