Instance Method

advanced(by:)

Returns a new value advanced by the given distance.

Declaration

func advanced(by amount: Float) -> Float

Parameters

amount

The distance to advance this value.

Return Value

A new value that is amount added to this value.

Discussion

For two values x and d, the result of a x.advanced(by: d) is equal to x + d—a new value y such that x.distance(to: y) approximates d. For example:

let x = 21.5
let y = x.advanced(by: -6.5)
// y == 15.0

print(x.distance(to: y))
// Prints "-6.5"

Relationships

From Protocol

See Also

Infrequently Used Functionality

init()

Creates a value initialized to zero.

init(integerLiteral: Int64)

Creates a new value from the given integer literal.

init(floatLiteral: Float)

Creates a new value from the given floating-point literal.

init(integerLiteral: Float)

Creates an instance initialized to the specified integer value.

func distance(to: Float) -> Float

Returns the distance from this value to the specified value.

func write<Target>(to: inout Target)

Writes a textual representation of this instance into the given output stream.