If you do not need to change h2 , then:
h1.each_with_object(h2) { |(k, v), h| h[k] += v }
If you want to leave only h2 :
h1.each_with_object(h2.dup) { |(k, v), h| h[k] += v }
And if you need this specific order:
h2.each_with_object(h1.dup) { |(k, v), h| h[k] += v }
source share