Ruby 3.4 リファレンスマニュアル

instance method Array#intersect?

intersect?(other) -> boolRuby 3.1 から[permalink][rdoc][edit]

other と共通の要素が少なくとも1個あれば true を、なければ false を返します。

a = [ 1, 2, 3 ]
b = [ 3, 4, 5 ]
c = [ 5, 6, 7 ]
p a.intersect?(b) # => true
p a.intersect?(c) # => false