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

# symmetricDifference(_:)

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

## Declaration

```swift
func symmetricDifference<S>(_ other: S) -> Set<Element> where Element == S.Element, S : Sequence
```

## Parameters

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

## 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 = ["Bethany", "Eric", "Forlani"] let eitherNeighborsOrEmployees = employees.symmetricDifference(neighbors) print(eitherNeighborsOrEmployees) // Prints "["Diana", "Forlani", "Alicia"]"

## See Also

### Combining Sets

- [union(_:)](swift/set/union(_:).md)
- [formUnion(_:)](swift/set/formunion(_:).md)
- [intersection(_:)](swift/set/intersection(_:)-1zh8f.md)
- [intersection(_:)](swift/set/intersection(_:)-6uts9.md)
- [formIntersection(_:)](swift/set/formintersection(_:).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)
