A sequence to insert between each of this sequence’s elements. このシーケンスの要素それぞれの間に挿入されるシーケンス。
Generic Instance Method
総称体インスタンスメソッド
joined(separator:)
Returns the concatenated elements of this sequence of sequences, inserting the given separator between each element.
各要素の間に与えられた分離子を挿入して、このシーケンスに属する複数のシーケンスの要素を鎖状に連結して返します。
Availability
- iOS 8.0+
- iPadOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 8.0+
Technology
- Swift Standard Library Swift標準ライブラリ
Declaration 宣言
func joined<Separator>(separator: Separator) -> JoinedSequence
<EmptyCollection
<Element>> where Separator : Sequence
, Separator.Element
== Element.Element
Available when
Element
conforms to Sequence
.
Element
がSequence
に準拠する時に利用可能です。
Parameters パラメータ
separator
Return Value 戻り値
The joined sequence of elements. つなぎ合わされたシーケンス要素。
Discussion 解説
This example shows how an array of [Int]
instances can be joined, using another [Int]
instance as the separator:
この例は、どのようにいくつかの[Int]
インスタンスからなる配列が別の[Int]
インスタンスを分離子として使ってつなぎ合わされるかを示します。
let nestedNumbers = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
let joined = nestedNumbers.joined(separator: [-1, -2])
print(Array(joined))
// Prints "[1, 2, 3, -1, -2, 4, 5, 6, -1, -2, 7, 8, 9]"