Comparing ruby hashes [duplicate]
here is a slightly modified version from colin’s. class Hash def diff(other) (self.keys + other.keys).uniq.inject({}) do |memo, key| unless self[key] == other[key] if self[key].kind_of?(Hash) && other[key].kind_of?(Hash) memo[key] = self[key].diff(other[key]) else memo[key] = [self[key], other[key]] end end memo end end end It recurses into the hashes for more efficient left and right {a: {c: 1, b: … Read more