Does anyone know how to do a blacklist in ruby?



I need to reject a few words when a user creates a comment, I need to know how I can do this without using a gem :frowning:

words = "a few words with some to block and prevent bad words"
blacklist = %w[bad block prevent]
words.split.delete_if {|word| blacklist.include? word }.join(' ')
# => "a few words with some to and words"