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

# contains(_:)

Returns a Boolean value that indicates whether the given element exists in the set.

## Declaration

```swift
func contains(_ member: Self.Element) -> Bool
```

## Parameters

- `member`: An element to look for in the set.

## Return Value

Return Value true if member exists in the set; otherwise, false.

## Discussion

Discussion This example uses the contains(_:) method to test whether an integer is a member of a set of prime numbers. let primes: Set = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] let x = 5 if primes.contains(x) {     print("\(x) is prime!") } else {     print("\(x). Not prime.") } // Prints "5 is prime!"

## See Also

### Testing for Membership

- [Element](swift/setalgebra/element.md)
