find subset of two hashes in ruby code example Example: find subset of two hashes in ruby hash3 = hash1.keep_if { |k, v| hash2.key? k }