<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Range/overlaps(_:)-9fkb2",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sn8overlapsySbSNyxGF"
  },
  "title" : "overlaps(_:)"
}
-->

# overlaps(_:)

Returns a Boolean value indicating whether this range and the given closed
range contain an element in common.

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

## Parameters

`other`

A closed range to check for elements in common.

## Return Value

`true` if this range and `other` have at least one element in
common; otherwise, `false`.

## Discussion

This example shows two overlapping ranges:

```
let x: Range = 0..<20
print(x.overlaps(10...1000))
// Prints "true"
```

Because a half-open range does not include its upper bound, the ranges
in the following example do not overlap:

```
let y = 20...30
print(x.overlaps(y))
// Prints "false"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)