protocol AbsoluteValuable
Inheritance |
Comparable, Equatable, IntegerLiteralConvertible, SignedNumberType
View Protocol Hierarchy →
|
---|---|
Associated Types | |
Import | import Swift |
Initializers
Create an instance initialized to value
.
Declaration
init(integerLiteral value: Self.IntegerLiteralType)
Declared In
IntegerLiteralConvertible
Static Methods
Returns the absolute value of x
.
Declaration
static func abs(x: Self) -> Self
Instance Methods
A strict total order
over instances of Self
.
Declaration
func <(lhs: Self, rhs: Self) -> Bool
Declared In
Comparable
Returns true
if lhs
is equal to rhs
.
Equality implies substitutability. When x == y
, x
and
y
are interchangeable in any code that only depends on their
values.
Class instance identity as distinguished by triple-equals ===
is notably not part of an instance's value. Exposing other
non-value aspects of Equatable
types is discouraged, and any
that are exposed should be explicitly pointed out in
documentation.
Equality is an equivalence relation
x == x
istrue
x == y
impliesy == x
x == y
andy == z
impliesx == z
Inequality is the inverse of equality, i.e. !(x == y)
iff
x != y
.
Declaration
func ==(lhs: Self, rhs: Self) -> Bool
Declared In
Equatable
Returns the result of negating x
.
Declaration
prefix func -(x: Self) -> Self
Declared In
SignedNumberType
Returns the difference between lhs
and rhs
.
Declaration
func -(lhs: Self, rhs: Self) -> Self
Declared In
SignedNumberType
A type that supports an "absolute value" function.