distance(from:to:)
Returns the distance between two indices.
Declaration
func distance(from start: String.UTF16View.Index, to end: String.UTF16View.Index) -> IntParameters
- start:
A valid index of the collection.
- end:
Another valid index of the collection. If
endis equal tostart, the result is zero.
Return Value
The distance between start and end. The result can be negative only if the collection conforms to the BidirectionalCollection protocol.
Discussion
Unless the collection conforms to the BidirectionalCollection protocol, start must be less than or equal to end.