Skip to content

Commit

Permalink
Update documentation for intersect?/disjoint?
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jun 18, 2021
1 parent 1a73ab9 commit 35b69e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,13 @@ def <=>(set)
end
end

# Returns true if the set and the given set have at least one
# Returns true if the set and the given enumerable have at least one
# element in common.
#
# Set[1, 2, 3].intersect? Set[4, 5] #=> false
# Set[1, 2, 3].intersect? Set[3, 4] #=> true
# Set[1, 2, 3].intersect? 4..5 #=> false
# Set[1, 2, 3].intersect? [3, 4] #=> true
def intersect?(set)
case set
when Set
Expand All @@ -488,11 +490,13 @@ def intersect?(set)
end
end

# Returns true if the set and the given set have no element in
# common. This method is the opposite of `intersect?`.
# Returns true if the set and the given enumerable have
# no element in common. This method is the opposite of `intersect?`.
#
# 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
def disjoint?(set)
!intersect?(set)
end
Expand Down

0 comments on commit 35b69e9

Please sign in to comment.