Skip to content
Browse files

Merge pull request #15440 from ilikepi/pr_docs_activesupport_hwia_dup

HashWithIndifferentAccess#dup doc [ci skip]
  • Loading branch information...
2 parents 2c51c40 + f803b82 commit 4f319ce37062fefe67841c53c4367db5ca934fb2 @zzak zzak committed
Showing with 8 additions and 1 deletion.
  1. +8 −1 activesupport/lib/active_support/hash_with_indifferent_access.rb
View
9 activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -176,7 +176,14 @@ def values_at(*indices)
indices.collect { |key| self[convert_key(key)] }
end
- # Returns an exact copy of the hash.
+ # 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"
def dup
self.class.new(self).tap do |new_hash|
new_hash.default = default

0 comments on commit 4f319ce

Please sign in to comment.
Something went wrong with that request. Please try again.