Generic Operator

+(_:_:)

Creates a new collection by concatenating the elements of a collection and a sequence. あるコレクションとあるシーケンスの要素を連結することによって新しいコレクションを作成します。

Declaration 宣言

static func + <Other>(lhs: Data, rhs: Other) -> Data where Other : Sequence, UInt8 == Other.Element

Parameters パラメータ

lhs

A range-replaceable collection. 範囲置換可能なコレクション。

rhs

A collection or finite sequence. あるコレクションまたは有限シーケンス。

Discussion 議論

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. 2つの引数は、同じElement型を持たなければなりません。例えば、あなたは整数配列の要素それらとあるRange<Int>インスタンスを連結できます。


let numbers = [1, 2, 3, 4]
let moreNumbers = numbers + (5...10)
print(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]. 結果のコレクションは、左手側での引数の型を持ちます。上の例では、moreNumbersnumbersと同じ型を持ちます、それは[Int]です。