From 4a3c4ac72cbbcfbdcfdac991ca28d40c9887332a Mon Sep 17 00:00:00 2001 From: Herwin Date: Tue, 24 Sep 2024 14:47:32 +0200 Subject: [PATCH] Update Set#merge for Ruby 3.3 behaviour Support multiple arguments --- lib/set.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/set.rb b/lib/set.rb index 08a31e29b..1e0fbbaf6 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -288,11 +288,13 @@ def each(&block) end end - def merge(other) - unless other.is_a?(Enumerable) - raise ArgumentError, "value must be enumerable" + def merge(*others) + others.each do |other| + unless other.is_a?(Enumerable) + raise ArgumentError, "value must be enumerable" + end + other.each { |element| add(element) } end - other.each { |element| add(element) } self end