Skip to content
instance method · added in Ruby 3.1

Array#intersect?

(::_ToAry[untyped]) -> bool
intersect?(other_array) → true or false

Returns whether other_array has at least one element that is eql? to some element of self:

Example
[1, 2, 3].intersect?([3, 4, 5]) # => true
[1, 2, 3].intersect?([4, 5, 6]) # => false

Each element must correctly implement method hash.

Related: see Methods for Querying.

Ruby version changes

  1. 3.1
See also #inspect #intersection #insert #join also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1