<!--
{
  "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/~=(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Operator",
  "symbol" : {
    "kind" : "Operator",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SXsE2teoiySbx_5BoundQztFZ::SYNTHESIZED::s:Sn"
  },
  "title" : "~=(_:_:)"
}
-->

# ~=(_:_:)

Returns a Boolean value indicating whether a value is included in a
range.

```
static func ~= (pattern: Self, value: Self.Bound) -> Bool
```

## Parameters

`pattern`

A range.

`value`

A value to match against `pattern`.

## Discussion

You can use the pattern-matching operator (`~=`) to test whether a value
is included in a range. The pattern-matching operator is used
internally in `case` statements for pattern matching. The following
example uses the `~=` operator to test whether an integer is included in
a range of single-digit numbers:

```
let chosenNumber = 3
if 0..<10 ~= chosenNumber {
    print("\(chosenNumber) is a single digit.")
}
// Prints "3 is a single digit."
```

---

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)