---
title: "formSymmetricDifference(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/setalgebra/formsymmetricdifference(_:)"
---

# formSymmetricDifference(_:)

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

## Declaration

```swift
mutating func formSymmetricDifference(_ other: Self)
```

## Parameters

- `other`: A set of the same type.

## Discussion

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 "Bethany" and "Eric" are removed from employees while the name "Forlani" is added. var employees: Set = ["Alicia", "Bethany", "Diana", "Eric"] let neighbors: Set = ["Bethany", "Eric", "Forlani"] employees.formSymmetricDifference(neighbors) print(employees) // Prints "["Diana", "Forlani", "Alicia"]"

## See Also

### Combining Sets

- [union(_:)](swift/setalgebra/union(_:).md)
- [formUnion(_:)](swift/setalgebra/formunion(_:).md)
- [intersection(_:)](swift/setalgebra/intersection(_:).md)
- [formIntersection(_:)](swift/setalgebra/formintersection(_:).md)
- [symmetricDifference(_:)](swift/setalgebra/symmetricdifference(_:).md)
