Returns the distance from this value to the specified value.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
Parameters
otherA value to calculate the distance to.
Return Value
The distance between this value and other.
Discussion
For two values x and y, the result of x is equal to y - x—a distance d such that x approximates y. For example:
let x = 21.5
let d = x.distance(to: 15.0)
// d == -6.5
print(x.advanced(by: d))
// Prints "15.0"