Inserts the elements of the given sequence into the set.
SDK
- Xcode 10.2+
Framework
- Swift Standard Library
Declaration
mutating func formUnion<S>(_ other: S) where Element == S.Element, S : Sequence
Parameters
otherA sequence of elements.
othermust be finite.
Discussion
If the set already contains one or more elements that are also in other, the existing members are kept. If other contains multiple instances of equivalent elements, only the first instance is kept.
var attendees: Set = ["Alicia", "Bethany", "Diana"]
let visitors = ["Diana", "Marcia", "Nathaniel"]
attendees.formUnion(visitors)
print(attendees)
// Prints "["Diana", "Nathaniel", "Bethany", "Alicia", "Marcia"]"