Instance Method

joined()

Returns the elements of this sequence of sequences, concatenated.

Declaration

func joined() -> FlattenSequence<Self>
Available when Element conforms to Sequence.

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.

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

func split(separator: Self.Element, maxSplits: Int, omittingEmptySubsequences: Bool) -> [Self.SubSequence]

Returns the longest possible subsequences of the sequence, in order, around elements equal to the given element.

func joined(separator: String) -> String

Returns a new string by concatenating the elements of the sequence, adding the given separator between each element.

func joined<Separator>(separator: Separator) -> JoinedSequence<Self>

Returns the concatenated elements of this sequence of sequences, inserting the given separator between each element.