# Hash Merge obj1 = { a: 10, b: 20 } obj2 = { c: 30, a: 40 } obj1.merge(obj2) # {:a=>40, :b=>20, :c=>30} # If no block is specified, entries with duplicate keys are overwritten with the values from other_hash, otherwise the value of each duplicate key is determined by calling the block with the key, its value in hsh and its value in other_hash. puts(obj1.merge(obj2) { |_key, v1, _v2| v1 }) # {:a=>10, :b=>20, :c=>30}