"Can't convert String into Array" error!?


#1
text = gets.chomp
text.downcase!
puts "second time"
redact = gets.chomp
redact.downcase!
redacted_words = redact.split(" ")
words = text.split(" ")
words.each { |words|
unless (redacted_words - words).empty?
    print words + " "
else
    print  "Redacted "
end
}

#2

What are you trying to do?

In your code,

redacted_words - words

is trying to subtract a string from an array of strings. This is not allowed. Here is the output you get when you try doing that (I'm using the interactive Ruby interpreter, irb)

nbk@somewhere:~/dev/Ruby/codeacademy$ irb
irb(main):001:0> my_string = "Hello"
=> "Hello"
irb(main):002:0> my_array_of_strings = ["Hello", "World", "How", "Are", "You"]
=> ["Hello", "World", "How", "Are", "You"]
irb(main):003:0> my_array_of_strings - my_string
TypeError: can't convert String into Array
	from (irb):3:in `-'
	from (irb):3
	from /usr/bin/irb:12:in `<main>'