From 5d5ff6e5eda887b39691db4db58ac1c2c3a1f8d9 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Fri, 24 Feb 2023 17:37:00 +0900 Subject: [PATCH] [ruby/set] Set#merge does not take keyword arguments as a Hash https://github.com/ruby/set/commit/ca1c9532a9 --- lib/set.rb | 2 +- lib/set/set.gemspec | 2 +- test/test_set.rb | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/set.rb b/lib/set.rb index 9140d024cf..95dd9217b1 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -598,7 +598,7 @@ class Set # Merges the elements of the given enumerable objects to the set and # returns self. - def merge(*enums) + def merge(*enums, **nil) enums.each do |enum| if enum.instance_of?(self.class) @hash.update(enum.instance_variable_get(:@hash)) diff --git a/lib/set/set.gemspec b/lib/set/set.gemspec index 0def52e859..1e83287420 100644 --- a/lib/set/set.gemspec +++ b/lib/set/set.gemspec @@ -8,7 +8,7 @@ Gem::Specification.new do |spec| spec.description = %q{Provides a class to deal with collections of unordered, unique values} spec.homepage = "https://github.com/ruby/set" spec.licenses = ["Ruby", "BSD-2-Clause"] - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") + spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0") spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage diff --git a/test/test_set.rb b/test/test_set.rb index e2a0f88f5b..49dc58ef7b 100644 --- a/test/test_set.rb +++ b/test/test_set.rb @@ -600,6 +600,10 @@ class TC_Set < Test::Unit::TestCase ret = set.merge([2,4,6], Set[4,5,6]) assert_same(set, ret) assert_equal(Set[1,2,3,4,5,6], set) + + assert_raise(ArgumentError) { + Set[].merge(a: 1) + } end def test_subtract