Generic Operator

+(_:_:)

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

Declaration 宣言

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

Parameters パラメータ

lhs

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

rhs

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

Discussion 解説

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


let numbers = [7, 8, 9, 10]
let moreNumbers = (1...6) + numbers
print(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]. 結果となるコレクションは、右手側の引数の型を持ちます。上の例において、moreNumbersnumbersと同じ型を持ちます、それは[Int]です。

See Also 参照

Combining Arrays 配列を結合する