Here's an extension function on Dictionary
in Swift that takes in another dictionary and returns the difference between the two:
main.swift351 chars14 lines
You can use this function to find the difference between two maps like this:
main.swift140 chars6 lines
In this example, the output is ["b": 2, "c": 3]
because map1
has a different value for the key "b" compared to map2
, and map1
also has a key "c" that is not in map2
.
gistlibby LogSnag