operator
+ {
associativity
left
precedence
}
Declarations
Creates a new collection by concatenating the elements of a collection and a sequence.
The two arguments must have the same Element
type. For example, you can
concatenate the elements of an integer array and a Range<Int>
instance.
let
numbers
= [
1
,
2
,
3
,
4
]
let
moreNumbers
=
numbers
+
5
...
10
(
moreNumbers
)
// Prints "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
The resulting collection has the type of the argument on the left-hand
side. In the example above, moreNumbers
has the same type as numbers
,
which is [Int]
.
Parameters: lhs: A range-replaceable collection. rhs: A collection or finite sequence.
Declaration
func
+
<
C
:
RangeReplaceableCollection
,
S
:
Sequence
where
S
.
Iterator
.
Element
==
C
.
Iterator
.
Element
>
(
lhs
:
C
,
rhs
:
S
) -
>
C
Creates a new collection by concatenating the elements of a sequence and a collection.
The two arguments must have the same Element
type. For example, you can
concatenate the elements of a Range<Int>
instance and an integer array.
let
numbers
= [
7
,
8
,
9
,
10
]
let
moreNumbers
=
1
...
6
+
numbers
(
moreNumbers
)
// Prints "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
The resulting collection has the type of argument on the right-hand side.
In the example above, moreNumbers
has the same type as numbers
, which
is [Int]
.
Parameters: lhs: A collection or finite sequence. rhs: A range-replaceable collection.
Declaration
func
+
<
C
:
RangeReplaceableCollection
,
S
:
Sequence
where
S
.
Iterator
.
Element
==
C
.
Iterator
.
Element
>
(
lhs
:
S
,
rhs
:
C
) -
>
C
Declaration
func
+
<
Pointee
>
(
lhs
:
Int
,
rhs
:
UnsafeMutablePointer
<
Pointee
>
) -
>
UnsafeMutablePointer
<
Pointee
>
Declaration
func
+
<
Pointee
>
(
lhs
:
Int
,
rhs
:
UnsafePointer
<
Pointee
>
) -
>
UnsafePointer
<
Pointee
>
Note: The following family of operator overloads are redundant with Strideable. However, optimizer improvements are needed before they can be removed without affecting performance.
Declaration
func
+
<
Pointee
>
(
lhs
:
UnsafeMutablePointer
<
Pointee
>
,
rhs
:
Int
) -
>
UnsafeMutablePointer
<
Pointee
>
Note: The following family of operator overloads are redundant with Strideable. However, optimizer improvements are needed before they can be removed without affecting performance.
Declaration
func
+
<
Pointee
>
(
lhs
:
UnsafePointer
<
Pointee
>
,
rhs
:
Int
) -
>
UnsafePointer
<
Pointee
>
Creates a new collection by concatenating the elements of two collections.
The two arguments must have the same Element
type. For example, you can
concatenate the elements of two integer arrays.
let
lowerNumbers
= [
1
,
2
,
3
,
4
]
let
higherNumbers
:
ContiguousArray
= [
5
,
6
,
7
,
8
,
9
,
10
]
let
allNumbers
=
lowerNumbers
+
higherNumbers
(
allNumbers
)
// Prints "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
The resulting collection has the type of the argument on the left-hand
side. In the example above, moreNumbers
has the same type as numbers
,
which is [Int]
.
Parameters: lhs: A range-replaceable collection. rhs: Another range-replaceable collection.
Declaration
func
+
<
RRC1
:
RangeReplaceableCollection
,
RRC2
:
RangeReplaceableCollection
where
RRC1
.
Iterator
.
Element
==
RRC2
.
Iterator
.
Element
>
(
lhs
:
RRC1
,
rhs
:
RRC2
) -
>
RRC1
Adds lhs
and rhs
, returning the result and trapping in case of
arithmetic overflow (except in -Ounchecked builds).
Declaration
func
+
<
T
:
_IntegerArithmetic
>
(
lhs
:
T
,
rhs
:
T
) -
>
T
Declaration
func
+
<
T
:
FloatingPoint
>
(
lhs
:
T
,
rhs
:
T
) -
>
T
Declaration
func
+
<
T
:
Strideable
>
(
lhs
:
T
,
rhs
:
T
.
Stride
) -
>
T
Declaration
func
+
<
T
:
Strideable
>
(
lhs
:
T
.
Stride
,
rhs
:
T
) -
>
T
Declaration
func
+
<
T
:
UnsignedInteger
>
(
lhs
:
T
,
rhs
:
T
.
_DisallowMixedSignArithmetic
) -
>
T
Declaration
func
+
<
T
:
UnsignedInteger
>
(
lhs
:
T
.
_DisallowMixedSignArithmetic
,
rhs
:
T
) -
>
T
Declaration
func
+(
lhs
:
Double
,
rhs
:
Double
) -
>
Double