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

# contains(_:)

Returns a Boolean value indicating whether the given closed range is contained within this range.

## Declaration

```swift
func contains(_ other: ClosedRange<Bound>) -> Bool
```

## Parameters

- `other`: A closed range to check for containment within this range.

## Return Value

Return Value true if other is wholly contained within this range; otherwise, false.

## Discussion

Discussion The given closed range is contained within this range if its bounds are contained within this range. If this range is empty, it cannot contain a closed range, since closed ranges by definition contain their boundaries. let range = 0..<10 range.contains(2...5)        // true range.contains(2...10)       // false range.contains(2...12)       // false

let emptyRange = 3..<3 emptyRange.contains(3...3)   // false note: O(1)
