instance method
deep_dup
Ruby on Rails 4.2.9
Since v3.1.12Signature
deep_dup()
Returns a deep copy of hash.
hash = { a: { b: 'b' } } dup = hash.deep_dup dup[:a][:c] = 'c' hash[:a][:c] # => nil dup[:a][:c] # => "c"
Source
# File activesupport/lib/active_support/core_ext/object/deep_dup.rb, line 41
def deep_dup
each_with_object(dup) do |(key, value), hash|
hash[key.deep_dup] = value.deep_dup
end
end
Defined in activesupport/lib/active_support/core_ext/object/deep_dup.rb line 41
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Hash