Replace this set with the elements contained in this set or the given set, but not both.
SDK
- Xcode 10.2+
Framework
- Swift Standard Library
Declaration
mutating func formSymmetricDifference<S>(_ other: S) where Element == S.Element, S : Sequence
Parameters
otherA sequence of elements.
othermust be finite.
Discussion
In the following example, the elements of the employees set that are also members of neighbors are removed from employees, while the elements of neighbors that are not members of employees are added to employees. In particular, the names "Bethany" and "Eric" are removed from employees while the name "Forlani" is added.
var employees: Set = ["Alicia", "Bethany", "Diana", "Eric"]
let neighbors = ["Bethany", "Eric", "Forlani"]
employees.formSymmetricDifference(neighbors)
print(employees)
// Prints "["Diana", "Forlani", "Alicia"]"