<!--
{
  "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/formSymmetricDifference(_:)-22p0m",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sh23formSymmetricDifferenceyyShyxGnF"
  },
  "title" : "formSymmetricDifference(_:)"
}
-->

# formSymmetricDifference(_:)

Removes the elements of the set that are also in the given sequence and
adds the members of the sequence that are not already in the set.

```
mutating func formSymmetricDifference(_ other: Set<Element>)
```

## Parameters

`other`

Another set.

## Discussion

In the following example, the elements of the `employees` set that are
also members of `neighbors` are removed from `employees`, while the
elements of `neighbors` that are not members of `employees` are added to
`employees`. In particular, the names `"Alicia"`, `"Chris"`, and
`"Diana"` are removed from `employees` while the names `"Forlani"` and
`"Greta"` are added.

```
var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"]
let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"]
employees.formSymmetricDifference(neighbors)
print(employees)
// Prints "["Diana", "Chris", "Forlani", "Alicia", "Greta"]"
```

---

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)