Sets operations in Swift
Forums:
let first: Set = [1, 2, 3]
let second: Set = [3, 4, 5]
var third = first.union(second)
//third is [1, 2, 3, 4, 5]
third = first.subtract(second)
//third is [1, 2]
third = first.intersect(second)
//third is [3]
third = first.exclusiveOr(second)
//third is [1, 2, 4, 5]
- Log in to post comments