Returns a new set containing the elements of this set that do not occur in the given sequence.
SDK
- Xcode 8.3+
Framework
- Swift Standard Library
Declaration
Parameters
otherA sequence of elements.
othermust be finite.
Return Value
A new set.
Discussion
In the following example, the non set is made up of the elements of the employees set that are not elements of neighbors:
let employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
let neighbors = ["Bethany", "Eric", "Forlani", "Greta"]
let nonNeighbors = employees.subtracting(neighbors)
print(nonNeighbors)
// Prints "["Chris", "Diana", "Alicia"]"