Skip to content

Commit

Permalink
Update Set#merge for Ruby 3.3 behaviour
Browse files Browse the repository at this point in the history
Support multiple arguments
  • Loading branch information
herwinw committed Sep 24, 2024
1 parent f7b8a73 commit 4a3c4ac
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4a3c4ac

Please sign in to comment.