Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Set#disjoint?

disjoint?(set)

Returns true if the set and the given enumerable have no element in common. This method is the opposite of intersect?.

Example
Set[1, 2, 3].disjoint? Set[3, 4]   #=> false
Set[1, 2, 3].disjoint? Set[4, 5]   #=> true
Set[1, 2, 3].disjoint? [3, 4]      #=> false
Set[1, 2, 3].disjoint? 4..5        #=> true
See also #difference #divide #delete_if #each also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0