A range expression that represents the entire range of a collection.
- Xcode 9.0+
- Swift Standard Library
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
count, 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,
Substring, a string’s slice type, for its parameters.
count with two strings, use an unbounded range in each string’s subscript.