Ruby - Hashes
What will be the output of the following Ruby code?
h1 = {x: 5, y: 10}h2 = {y: 15, z: 20}result = h1.merge(h2)
puts result
What will be the output of the following Ruby code?
h1 = {x: 5, y: 10}h2 = {y: 15, z: 20}result = h1.merge(h2)
puts result
merge method returns a new hash combining keys and values from both hashes.h2) overwrite those in the original (h1).h2 (15).15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions