From cafa7d897554320b5194f5d71d6a3936f954b484 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 15 Jun 2021 15:14:54 -0700 Subject: [PATCH] [ruby/set] Allow the use of any enumerable in intersect?/disjoint? https://github.com/ruby/set/commit/1a73ab9047 --- lib/set.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/set.rb b/lib/set.rb index ec4dabdfca..8ed6e807c7 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -476,16 +476,15 @@ class 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