Compare two Maps in Scala
Try:
val diff = (m1.keySet -- m2.keySet) ++ (m2.keySet -- m1.keySet)
diff
contains the elements that are in m1
and not in m2
and that are in m2
and not in m1
.
Consider the difference between the maps converted into sets of tuples,
(m1.toSet diff m2.toSet).toMap