merge method merges two hashes together, producing a copy of the hashes that removes duplicate keys by overwriting the key-value pairs from the merged array. : merge « Hash « Ruby






merge method merges two hashes together, producing a copy of the hashes that removes duplicate keys by overwriting the key-value pairs from the merged array.


myHash2 = { 1 => "Two", 2 => "New Value", 3 => "New Three" }
myHash = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five" }


myHash.merge myHash2 

p myHash

 








Related examples in the same category

1.Merge two hashes
2.Merge two hashes with block logics
3.using merge with a block