Negatable
public protocol Negatable : AdditiveArithmetic
A type that can be additively inverted.
Note
UnlikeSignedNumber, Negatable types do not need to conform to Comparable, allowing conformance by two‐dimensional vectors, etc.
Conformance Requirements:
-
−(_:)Default implementationReturns the additive inverse of the operand.
Mutating variant
−=
Recommended over
-
Default Implementation
Returns the additive inverse of the operand.
Mutating variant
−=
Recommended over
-
Declaration
Swift
static prefix func − (operand: Self) -> SelfParameters
operandThe value to invert.
-
−=(_:)Default implementationSets the operand to its additive inverse.
Nonmutating variant
−
Default Implementation
Sets the operand to its additive inverse.
Nonmutating variant
−
Declaration
Swift
static postfix func −= (operand: inout Self)Parameters
operandThe value to modify by inversion.
View on GitHub
Negatable Protocol Reference