<!--
{
  "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/UnboundedRange_",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s15UnboundedRange_O"
  },
  "title" : "UnboundedRange_"
}
-->

# UnboundedRange_

A range expression that represents the entire range of a collection.

```
@frozen enum UnboundedRange_
```

## Overview

You can use the unbounded range operator (`...`) to create a slice of a
collection that contains all of the collection’s elements. Slicing with an
unbounded range is essentially a conversion of a collection instance into
its slice type.

For example, the following code declares `countLetterChanges(_:_:)`, a
function that finds the number of changes required to change one
word or phrase into another. The function uses a recursive approach to
perform the same comparisons on smaller and smaller pieces of the original
strings. In order to use recursion without making copies of the strings at
each step, `countLetterChanges(_:_:)` uses `Substring`, a string’s slice
type, for its parameters.

```
func countLetterChanges(_ s1: Substring, _ s2: Substring) -> Int {
    if s1.isEmpty { return s2.count }
    if s2.isEmpty { return s1.count }

    let cost = s1.first == s2.first ? 0 : 1

    return min(
        countLetterChanges(s1.dropFirst(), s2) + 1,
        countLetterChanges(s1, s2.dropFirst()) + 1,
        countLetterChanges(s1.dropFirst(), s2.dropFirst()) + cost)
}
```

To call `countLetterChanges(_:_:)` with two strings, use an unbounded
range in each string’s subscript.

```
let word1 = "grizzly"
let word2 = "grisly"
let changes = countLetterChanges(word1[...], word2[...])
// changes == 2
```

## Topics

### Creating an Unbounded Range

[`...(_:)`](/documentation/Swift/UnboundedRange_/...(_:))

Creates an unbounded range expression.

[`UnboundedRange`](/documentation/Swift/UnboundedRange)

The type of an unbounded range operator.



---

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)