To simplify things let's say I have the hashes below.
I would like to find the keys that are in multiple hashes and the name of the hashes. So ideally I would like to end up with
A is also in a
A is also in b
B is also in a
B is also in b
D is also in b
D is also in c
E is also in b
E is also in c
The only way I can think of is: putting all keys in an array, sort it, remove unique elements, search each hash that contain the remaing array elements.
It is somewhat complicated and hacky I guess.
Question
Is there an easier way to find duplicate keys across hashes?
!/usr/bin/ruby
require 'ap'
a = {}
b = {}
c = {}
a["A"] = 1
a["B"] = 1
a["C"] = 1
b["A"] = 1
b["B"] = 1
b["D"] = 1
b["E"] = 1
c["D"] = 1
c["E"] = 1
c["F"] = 1