I have a feeling there’s a more elegant way to do this but here’s a way that will do this for hashes:
hash1 = {'blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4}
hash2 = {'green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8}
hash3 = {}
(hash1.keys - hash2.keys).each do |key|
hash3[key] = hash1[key]
end