<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Set/formUnion(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sh9formUnionyyqd__n7ElementQyd__RszSTRd__lF"
  },
  "title" : "formUnion(_:)"
}
-->

# formUnion(_:)

Inserts the elements of the given sequence into the set.

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

## Parameters

`other`

A sequence of elements. `other` must 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"]"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)