How can I check if a Ruby array includes one of several values?
Set intersect them: a1 & a2 Here’s an example: > a1 = [ ‘foo’, ‘bar’ ] > a2 = [ ‘bar’, ‘baz’ ] > a1 & a2 => [“bar”] > !(a1 & a2).empty? # Returns true if there are any elements in common => true