Operator: +=

operator += { associativity right precedence assignment }

Declarations

func +=(_: inout Double, rhs: Double)

Adds two values and stores the result in the left-hand-side variable, rounded to a representable value.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Double, rhs: Double)
func +=(_: inout Float, rhs: Float)

Adds two values and stores the result in the left-hand-side variable, rounded to a representable value.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Float, rhs: Float)
func +=(_: inout Float80, rhs: Float80)

Adds two values and stores the result in the left-hand-side variable, rounded to a representable value.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Float80, rhs: Float80)

Declared In

Float80, BinaryFloatingPoint, Strideable
func +=(_: inout Int, rhs: Int)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Int, rhs: Int)

Declared In

Int, FixedWidthInteger
func +=(_: inout Int8, rhs: Int8)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Int8, rhs: Int8)

Declared In

Int8, FixedWidthInteger
func +=(_: inout Int16, rhs: Int16)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Int16, rhs: Int16)

Declared In

Int16, FixedWidthInteger
func +=(_: inout Int32, rhs: Int32)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Int32, rhs: Int32)

Declared In

Int32, FixedWidthInteger
func +=(_: inout Int64, rhs: Int64)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout Int64, rhs: Int64)

Declared In

Int64, FixedWidthInteger
func +=(_: inout Self, rhs: Self.Stride)

Declaration

func +=(lhs: inout Self, rhs: Self.Stride)

Declared In

Strideable
func +=(_: inout Self, rhs: Self.Stride)

Declaration

func +=(lhs: inout Self, rhs: Self.Stride)

Declared In

Strideable
func +=(_: inout Self, rhs: Self.Stride)

Declaration

func +=(lhs: inout Self, rhs: Self.Stride)

Declared In

Strideable
func +=(_: inout Self, rhs: Self.Stride)

Declaration

func +=(lhs: inout Self, rhs: Self.Stride)

Declared In

Strideable
func +=(_: inout Self, rhs: Self.Stride)

Declaration

func +=(lhs: inout Self, rhs: Self.Stride)

Declared In

Strideable
func +=(_: inout String, rhs: String)

Declaration

func +=(lhs: inout String, rhs: String)
func +=(_: inout UInt, rhs: UInt)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout UInt, rhs: UInt)

Declared In

UInt, FixedWidthInteger
func +=(_: inout UInt8, rhs: UInt8)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout UInt8, rhs: UInt8)

Declared In

UInt8, FixedWidthInteger
func +=(_: inout UInt16, rhs: UInt16)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout UInt16, rhs: UInt16)

Declared In

UInt16, FixedWidthInteger
func +=(_: inout UInt32, rhs: UInt32)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout UInt32, rhs: UInt32)

Declared In

UInt32, FixedWidthInteger
func +=(_: inout UInt64, rhs: UInt64)

Adds two values and stores the result in the left-hand-side variable.

The sum of the two arguments must be representable in the arguments' type. In the following example, the result of 21 + 120 is greater than the maximum representable Int8 value:

var x: Int8 = 21
x += 120
// Overflow error

Note: Overflow checking is not performed in -Ounchecked builds.

Parameters: lhs: The first value to add. rhs: The second value to add.

Declaration

func +=(lhs: inout UInt64, rhs: UInt64)

Declared In

UInt64, FixedWidthInteger
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection
func += <Other>(_: inout Self, rhs: Other)

Appends the elements of a sequence to a range-replaceable collection.

Use this operator to append the elements of a sequence to the end of range-replaceable collection with same Element type. This example appends the elements of a Range<Int> instance to an array of integers.

var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"

Parameters: lhs: The array to append to. rhs: A collection or finite sequence.

Complexity: O(n), where n is the length of the resulting array.

Declaration

func +=<Other>(lhs: inout Self, rhs: Other)

Declared In

RangeReplaceableCollection