Apple has provided four methods that we can use to construct a set from two other sets. These operations can be performed in place, on one of the sets, or used to create a new set. These operations are as follows:
- union and formUnion: These create a set with all the unique values from both sets
- subtracting and subtract: These create a set with values from the first set that are not in the second set
- intersection and fromIntersection: These create a set with values that are common to both sets
- symmetricDifference and fromSymmetricDifference: These create a new set with values that are in either set, but not in both sets
Let's look at some examples and see the results that can be obtained from each of these operations. For ...