diff options
author | Zachary Scott <e@zzak.io> | 2014-05-30 17:26:06 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-05-30 17:26:06 -0700 |
commit | 4f319ce37062fefe67841c53c4367db5ca934fb2 (patch) | |
tree | 7dd90142f1639fc0d783a855e308688cb9b09904 | |
parent | 2c51c405e0eb75a1c3acc7f1ec0da4d4ee90cb30 (diff) | |
parent | f803b82a771a9aed33458760cc99415f8c63ab78 (diff) | |
download | rails-4f319ce37062fefe67841c53c4367db5ca934fb2.tar.gz rails-4f319ce37062fefe67841c53c4367db5ca934fb2.tar.bz2 rails-4f319ce37062fefe67841c53c4367db5ca934fb2.zip |
Merge pull request #15440 from ilikepi/pr_docs_activesupport_hwia_dup
HashWithIndifferentAccess#dup doc [ci skip]
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index a4ebdea598..ed41b28d54 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -176,7 +176,14 @@ module ActiveSupport 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 |