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

# symmetricDifference(_:)

Returns a new set with the elements that are either in this set or in the given set, but not in both.

## Declaration

```swift
func symmetricDifference(_ other: Self) -> Self
```

## Parameters

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

## Return Value

Return Value A new set.

## Discussion

Discussion In the following example, the eitherNeighborsOrEmployees set is made up of the elements of the employees and neighbors sets that are not in both employees and neighbors. In particular, the names "Bethany" and "Eric" do not appear in eitherNeighborsOrEmployees. let employees: Set = ["Alicia", "Bethany", "Diana", "Eric"] let neighbors: Set = ["Bethany", "Eric", "Forlani"] let eitherNeighborsOrEmployees = employees.symmetricDifference(neighbors) print(eitherNeighborsOrEmployees) // 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)
- [formSymmetricDifference(_:)](swift/setalgebra/formsymmetricdifference(_:).md)
