Instance Method


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


func advanced(by n: Int) -> Int



The distance to advance this value.

Return Value

A value that is offset from this value by n.


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.


From Protocol

See Also

Infrequently Used Functionality


Creates a new value equal to zero.

init(integerLiteral: Int)

Creates an instance initialized to the specified integer value.

typealias Int.IntegerLiteralType

A type that represents an integer literal.

func distance(to: Int) -> Int

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