---
title: "intersection(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/set/intersection(_:)-1zh8f"
---

# intersection(_:)

Returns a new set with the elements that are common to both this set and the given sequence.

## Declaration

```swift
func intersection(_ other: Set<Element>) -> Set<Element>
```

## Parameters

- `other`: Another set.

## Return Value

Return Value A new set.

## Discussion

Discussion In the following example, the bothNeighborsAndEmployees set is made up of the elements that are in both the employees and neighbors sets. Elements that are in only one or the other are left out of the result of the intersection. let employees: Set = ["Alicia", "Bethany", "Chris", "Diana", "Eric"] let neighbors: Set = ["Bethany", "Eric", "Forlani", "Greta"] let bothNeighborsAndEmployees = employees.intersection(neighbors) print(bothNeighborsAndEmployees) // Prints "["Bethany", "Eric"]"

## See Also

### Combining Sets

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