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

# formIntersection(_:)

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

## Declaration

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

## Parameters

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

## 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: Set = ["Bethany", "Eric", "Forlani", "Greta"] employees.formIntersection(neighbors) print(employees) // Prints "["Bethany", "Eric"]"

## See Also

### Combining Sets

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