How can the values from one hash be copied into another, but only for the keys that exist in both hashes?
Minimal example
h1 = {a: 10, b: 20, c: 30}
h2 = {a: nil, c: nil}
## desired result
{a: 10, c: 30}
I've solved with a 'manual' approach - i.e. {a: h1[:a], c: h1[:c]} - but it's verbose and looks worse the more keys there are. I'm sure there's something (much) more elegant?