The symmetricDifference method returns a set of unique elements that are in either the set the method is called on, or the set that's provided as a parameter, but not elements that are in both:
let squareOrTriangularNotBoth =
squareNumbers.symmetricDifference(triangularNumbers)
// 4, 9, 3, 6, 10, unordered
This set operation is sometimes referred to as method is so exclusiveOr, both other programming languages, including previous versions of Swift.
The following diagram depicts the Symmetric Difference of Set A and Set B:
Figure 2.4 – Symmetric difference