operator
+= {
associativity
right
precedence
assignment
}
Declarations
Appends the elements of a collection to an array.
Use this operator to append the elements of a collection to the end of
an array 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
(
numbers
)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"
Parameters: lhs: The array to append to. rhs: A collection.
Complexity: O(n), where n is the length of the resulting array.
Declaration
func
+=
<
C
:
Collection
>
(
lhs
:
inout
[
C
.
Iterator
.
Element
],
rhs
:
C
)
Appends the elements of a collection to an ArraySlice
instance.
Use this operator to append the elements of a collection to the end of
an ArraySlice
instance 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
(
numbers
)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"
Parameters: lhs: The array to append to. rhs: A collection.
Complexity: O(n), where n is the length of the resulting array.
Declaration
func
+=
<
C
:
Collection
>
(
lhs
:
inout
ArraySlice
<
C
.
Iterator
.
Element
>
,
rhs
:
C
)
Appends the elements of a collection to a ContiguousArray
instance.
Use this operator to append the elements of a collection to the end of
a ContiguousArray
instance 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
(
numbers
)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"
Parameters: lhs: The array to append to. rhs: A collection.
Complexity: O(n), where n is the length of the resulting array.
Declaration
func
+=
<
C
:
Collection
>
(
lhs
:
inout
ContiguousArray
<
C
.
Iterator
.
Element
>
,
rhs
:
C
)
Append the elements of rhs
to lhs
.
Declaration
func
+=
<
Element
,
C
:
Collection
where
C
.
Iterator
.
Element
==
Element
>
(
lhs
:
inout
_ContiguousArrayBuffer
<
Element
>
,
rhs
:
C
)
Declaration
func
+=
<
Pointee
>
(
lhs
:
inout
UnsafeMutablePointer
<
Pointee
>
,
rhs
:
Int
)
Declaration
func
+=
<
Pointee
>
(
lhs
:
inout
UnsafePointer
<
Pointee
>
,
rhs
:
Int
)
Appends the elements of a sequence to an array.
Use this operator to append the elements of a sequence to the end of
an array 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
(
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
+=
<
S
:
Sequence
>
(
lhs
:
inout
[
S
.
Iterator
.
Element
],
rhs
:
S
)
Appends the elements of a sequence to an ArraySlice
instance.
Use this operator to append the elements of a sequence to the end of
an ArraySlice
instance 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
(
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
+=
<
S
:
Sequence
>
(
lhs
:
inout
ArraySlice
<
S
.
Iterator
.
Element
>
,
rhs
:
S
)
Appends the elements of a sequence to a ContiguousArray
instance.
Use this operator to append the elements of a sequence to the end of
a ContiguousArray
instance 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
(
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
+=
<
S
:
Sequence
>
(
lhs
:
inout
ContiguousArray
<
S
.
Iterator
.
Element
>
,
rhs
:
S
)
Adds lhs
and rhs
and stores the result in lhs
, trapping in
case of arithmetic overflow (except in -Ounchecked builds).
Declaration
func
+=
<
T
:
_IntegerArithmetic
>
(
lhs
:
inout
T
,
rhs
:
T
)
Declaration
func
+=
<
T
:
FloatingPoint
>
(
lhs
:
inout
T
,
rhs
:
T
)
Declaration
func
+=
<
T
:
Strideable
>
(
lhs
:
inout
T
,
rhs
:
T
.
Stride
)
Declaration
func
+=
<
T
:
UnsignedInteger
>
(
lhs
:
inout
T
,
rhs
:
T
.
_DisallowMixedSignArithmetic
)
Declaration
func
+=(
lhs
:
inout
Double
,
rhs
:
Double
)