Instance MethodSwift

distance(to:)

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

func distance(to other: Int) -> Int

Parameters

other

The value to calculate the distance to.

Returns

The distance from this value to other.

Overview

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