Instance Method インスタンスメソッド

joined()

Returns the elements of this sequence of sequences, concatenated. このシーケンスに属する複数のシーケンスの要素を、鎖状に連結して返します。

Declaration 宣言

func joined() -> FlattenSequence<Array<Element>>
Available when Element conforms to Sequence. ElementSequenceに準拠する時に利用可能です。

Return Value 戻り値

A flattened view of the elements of this sequence of sequences. 複数のシーケンスからなるこのシーケンスの要素のある平坦なビュー。

Discussion 解説

In this example, an array of three ranges is flattened so that the elements of each range can be iterated in turn. この例において、3つの範囲からなる配列は平坦化されます、それで各範囲の要素は順に反復されることができます。


let ranges = [0..<3, 8..<10, 15..<17]


// A for-in loop over 'ranges' accesses each range:
for range in ranges {
  print(range)
}
// Prints "0..<3"
// Prints "8..<10"
// Prints "15..<17"


// Use 'joined()' to access each element of each range:
for index in ranges.joined() {
    print(index, terminator: " ")
}
// Prints: "0 1 2 8 9 15 16"

See Also 参照

Splitting and Joining Elements 要素の分割と連結