Instance MethodSwift

advanced(by:)

Returns a value that is offset the specified distance from this value.

func advanced(by n: Int) -> Int

Parameters

n

The distance to advance this value.

Returns

A value that is offset from this value by n.

Overview

Use the advanced(by:) method in generic code to offset a value by a specified distance. If you’re working directly with numeric values, use the addition operator (+) instead of this method.

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