Skip to content

Commit

Permalink
Allow the use of any enumerable in intersect?/disjoint?
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jun 15, 2021
1 parent d9b389b commit 1a73ab9
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,15 @@ def <=>(set)
def intersect?(set)
case set
when Set
# nothing
when Array
Set.new(set)
else
raise ArgumentError, "value must be a set or array"
end
if size < set.size
any? { |o| set.include?(o) }
else
if size < set.size
any? { |o| set.include?(o) }
else
set.any? { |o| include?(o) }
end
when Enumerable
set.any? { |o| include?(o) }
else
raise ArgumentError, "value must be enumerable"
end
end

Expand Down

0 comments on commit 1a73ab9

Please sign in to comment.