Instance Method

advanced(by:)

Returns a new value advanced by the given distance.

Declaration

func advanced(by amount: Double) -> Double

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(floatLiteral: Double)

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

init(integerLiteral: Int64)

Creates a new value from the given integer literal.

init(integerLiteral: Double)

Creates an instance initialized to the specified integer value.

func distance(to: Double) -> Double

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.