Addable

public protocol Addable

A type that can be used with +(_:_:).

The precise behaviour of + depends on the conforming type. It may be arithmetic addition, string concatenation, etc.

Conformance Requirements:

  • static func += (lhs: inout Self, rhs: Self)
  • +(_:_:) Default implementation

    Returns the sum, concatenation, or the result of a similar operation on two values implied by the “+” symbol. Exact behaviour depends on the type.

    Mutating variant

    +=

    Default Implementation

    Returns the sum of the two values.

    Mutating variant

    +=

    Declaration

    Swift

    static func + (lhs: Self, rhs: Self) -> Self

    Parameters

    lhs

    The starting value.

    rhs

    The value to add.

  • +=(_:_:) Default implementation

    Adds or concatenates the right value to the left, or performs a similar operation implied by the “+” symbol. Exact behaviour depends on the type.

    Nonmutating variant

    +

    Default Implementation

    Adds the right value to the left.

    Nonmutating variant

    +

    Declaration

    Swift

    static func += (lhs: inout Self, rhs: Self)

    Parameters

    lhs

    The value to modify.

    rhs

    The value to add.