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

# distance(to:)

Returns the distance from this value to the given value, expressed as a stride.

## Declaration

```swift
func distance(to other: Int) -> Int
```

## Parameters

- `other`: The value to calculate the distance to.

## Return Value

Return Value The distance from this value to other.

## Discussion

Discussion For two values x and y, and a distance n = x.distance(to: y), x.advanced(by: n) == y.

## See Also

### Infrequently Used Functionality

- [init()](swift/int/init().md)
- [init(integerLiteral:)](swift/int/init(integerliteral:).md)
- [Int.IntegerLiteralType](swift/int/integerliteraltype.md)
- [advanced(by:)](swift/int/advanced(by:).md)
- [Int.Stride](swift/int/stride.md)
- [hashValue](swift/int/hashvalue.md)
