Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift find difference between two arrays

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 by www.hackingwithswift.com #
 
PREVIOUS NEXT
Tagged: #swift #find #difference #arrays
ADD COMMENT
Topic
Name
9+8 =