class Hash
def deep_merge(other_hash, &block)
Experimental RBS support (using type sampling data from the type_fusion
project).
def deep_merge: (Hash other_hash, ) -> untyped
This signature was generated using 1 sample from 1 application.
h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
h2 = { b: 250, c: { c1: 200 } }
h1 = { a: 100, b: 200, c: { c1: 100 } }
to merge values:
Like with Hash#merge in the standard library, a block can be provided
h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
h2 = { a: false, b: { x: [3, 4, 5] } }
h1 = { a: true, b: { c: [1, 2, 3] } }
Returns a new hash with +self+ and +other_hash+ merged recursively.
def deep_merge(other_hash, &block) dup.deep_merge!(other_hash, &block) end