The complement is the mathematical term for what I'm looking for, but for context and possibly more targeted solution: I have hash A, which can have nested hashes (i.e. they're N-dimensional), and I apply to it a process (over which I have no control) which returns hash B, which is hash A with some elements removed. From there on, I am trying to find the elements in A which have been removed in B.
For example: (note that I use symbols for simplicity. Keys will always be symbols, but values won't.)
a = {:a => :b,
:c => {:d => :e, :f => :g},
:h => :i,
:j => {:k => :l, :m => :n},
:o => {:p => :q, :r => :s},
:t => :u}
b = {:h => :i,
:j => {:k => :l, :m => :n},
:o => {:r => :s},
:t => :u}
complement(a,b)
#=> {:a => :b,
# :c => {:d => :e, :f => :g},
# :o => {:p => :q}}
What is the best (ruby-esque) way of doing this?