Skip to content

Commit

Permalink
[ruby/set] The arity of initialize_clone is -1 in Ruby >= 3
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Dec 23, 2023
1 parent 271c74a commit 6fc3171
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/set.rb
Expand Up @@ -286,18 +286,10 @@ def initialize_dup(orig)
@hash = orig.instance_variable_get(:@hash).dup
end

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
# Clone internal hash.
def initialize_clone(orig, **options)
super
@hash = orig.instance_variable_get(:@hash).clone(**options)
end

def freeze # :nodoc:
Expand Down

0 comments on commit 6fc3171

Please sign in to comment.