End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Set#intersect?
intersect?(set)
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/set.rb, line 321
def intersect?(set)
set.is_a?(Set) or raise ArgumentError, "value must be a set"
if size < set.size
any? { |o| set.include?(o) }
else
set.any? { |o| include?(o) }
end
end
Returns true if the set and the given set have at least one element in common.
Example
Set[1, 2, 3].intersect? Set[4, 5] #=> false Set[1, 2, 3].intersect? Set[3, 4] #=> true