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

# formIntersection(_:)

Removes the elements of the set that aren’t also in the given sequence.

## Declaration

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

## Parameters

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

## Discussion

Discussion In the following example, the elements of the employees set that are not also members of the neighbors set are removed. In particular, the names "Alicia", "Chris", and "Diana" are removed. var employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"] let neighbors = ["Bethany", "Eric", "Forlani", "Greta"] employees.formIntersection(neighbors) print(employees) // Prints "["Bethany", "Eric"]"

## 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)
- [symmetricDifference(_:)](swift/set/symmetricdifference(_:).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)
