Instance Method (Default implementation)swift 6.0.1Swift
union(_:)
Returns a new option set of the elements contained in this set, in the given set, or in both.
func union(_ other: Self) -> Self
Parameters
- other
An option set.
Returns
A new option set made up of the elements contained in this set, in other
, or in both.
This example uses the union(_:)
method to add two more shipping options to the default set.
let defaultShipping = ShippingOptions.standard
let memberShipping = defaultShipping.union([.secondDay, .priority])
print(memberShipping.contains(.priority))
// Prints "true"
Implements
func union(Self
) -> Self Returns a new set with the elements of both this and the given set.
Other members in extension
Instance members
func intersection(Self
) -> Self Returns a new option set with only the elements contained in both this set and the given set.
func symmetricDifference(Self
) -> Self Returns a new option set with the elements contained in this set or in the given set, but not in both.