Question : swift find difference between two arrays
Answered by : upset-unicorn-62eall96mf2f
extension Array where Element: Hashable { func difference(from other: [Element]) -> [Element] { let thisSet = Set(self) let otherSet = Set(other) return Array(thisSet.symmetricDifference(otherSet)) }
}
Source : https://www.hackingwithswift.com/example-code/language/how-to-find-the-difference-between-two-arrays | Last Update : Fri, 04 Dec 20