Operator (Default Implementation)Swift5.9.0


    Returns the additive inverse of the specified value.

    static func - (operand: Self) -> Self


    The additive inverse of the argument.

    The negation operator (prefix -) returns the additive inverse of its argument.

    let x = 21
    let y = -x
    // y == -21

    The resulting value must be representable in the same type as the argument. In particular, negating a signed, fixed-width integer type’s minimum results in a value that cannot be represented.

    let z = -Int8.min
    // Overflow error