instance method
dup
Ruby on Rails 5.2.8.1
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 254
def dup
self.class.new(self).tap do |new_hash|
set_defaults(new_hash)
end
end
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 254
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess