---
title: "distance(from:to:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/uint/words-swift.struct/distance(from:to:)"
---

# distance(from:to:)

Returns the distance between two indices.

## Declaration

```swift
func distance(from start: Self.Index, to end: Self.Index) -> Self.Index.Stride
```

## Parameters

- `start`: A valid index of the collection.
- `end`: Another valid index of the collection. If end is equal to start, the result is zero.

## Return Value

Return Value The distance between start and end.

## Discussion

Discussion note: O(1)
