Instance MethodSwift

distance(from:to:)

Returns the distance between two indices.

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.

Returns

The distance between start and end.