diff options
-rw-r--r-- | lib/set.rb | 16 | ||||
-rw-r--r-- | test/test_set.rb | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/set.rb b/lib/set.rb index d405d81178..844d52ed54 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -136,10 +136,18 @@ class Set @hash = orig.instance_variable_get(:@hash).dup end - # Clone internal hash. - def initialize_clone(orig, freeze: nil) - super - @hash = orig.instance_variable_get(:@hash).clone(freeze: freeze) + if Kernel.instance_method(:initialize_clone).arity != 1 + # Clone internal hash. + def initialize_clone(orig, **options) + super + @hash = orig.instance_variable_get(:@hash).clone(**options) + end + else + # Clone internal hash. + def initialize_clone(orig) + super + @hash = orig.instance_variable_get(:@hash).clone + end end def freeze # :nodoc: diff --git a/test/test_set.rb b/test/test_set.rb index 86f860222c..acb1cebe16 100644 --- a/test/test_set.rb +++ b/test/test_set.rb @@ -739,7 +739,7 @@ class TC_Set < Test::Unit::TestCase set2.add 5 assert_equal Set[1,2,3,5], set2 assert_equal Set[1,2,3], set1 - end + end if Kernel.instance_method(:initialize_clone).arity != 1 def test_inspect set1 = Set[1, 2] |