---
title: "formUnion(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/set/formunion(_:)"
---

# formUnion(_:)

Inserts the elements of the given sequence into the set.

## Declaration

```swift
mutating func formUnion<S>(_ other: S) where Element == S.Element, S : Sequence
```

## Parameters

- `other`: A sequence of elements. other must be finite.

## Discussion

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"]"

## See Also

### Combining Sets

- [union(_:)](swift/set/union(_:).md)
- [intersection(_:)](swift/set/intersection(_:)-1zh8f.md)
- [intersection(_:)](swift/set/intersection(_:)-6uts9.md)
- [formIntersection(_:)](swift/set/formintersection(_:).md)
- [symmetricDifference(_:)](swift/set/symmetricdifference(_:).md)
- [formSymmetricDifference(_:)](swift/set/formsymmetricdifference(_:)-22p0m.md)
- [formSymmetricDifference(_:)](swift/set/formsymmetricdifference(_:)-5u38b.md)
- [subtract(_:)](swift/set/subtract(_:)-8gc48.md)
- [subtract(_:)](swift/set/subtract(_:)-7cd3y.md)
- [subtracting(_:)](swift/set/subtracting(_:)-3n4lc.md)
- [subtracting(_:)](swift/set/subtracting(_:)-2qge3.md)
