instance method
dup
Ruby on Rails 8.0.4
Since v3.0.20Signature
dup()
Returns a shallow copy of the hash.
hash = ActiveSupport::HashWithIndifferentAccess.new({ a: { b: 'b' } }) dup = hash.dup dup[:a][:c] = 'c' hash[:a][:c] # => "c" dup[:a][:c] # => "c"
Source
# File activesupport/lib/active_support/hash_with_indifferent_access.rb, line 264
def dup
copy_defaults(self.class.new(self))
end
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 264
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess