---
title: "distance(from:to:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/array/distance(from:to:)"
---

# distance(from:to:)

Returns the distance between two indices.

## Declaration

```swift
func distance(from start: Int, to end: Int) -> Int
```

## 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.

## See Also

### Manipulating Indices

- [startIndex](swift/array/startindex.md)
- [endIndex](swift/array/endindex.md)
- [index(after:)](swift/array/index(after:).md)
- [formIndex(after:)](swift/array/formindex(after:).md)
- [index(before:)](swift/array/index(before:).md)
- [formIndex(before:)](swift/array/formindex(before:).md)
- [index(_:offsetBy:)](swift/array/index(_:offsetby:).md)
- [formIndex(_:offsetBy:)](swift/array/formindex(_:offsetby:).md)
- [index(_:offsetBy:limitedBy:)](swift/array/index(_:offsetby:limitedby:).md)
- [formIndex(_:offsetBy:limitedBy:)](swift/array/formindex(_:offsetby:limitedby:).md)
