Generic Instance Method

flatMap(_:)

Returns the concatenated results of mapping the given transformation over this sequence.

Declaration

func flatMap<SegmentOfResult>(_ transform: @escaping (Base.Element) -> SegmentOfResult) -> LazySequence<FlattenSequence<LazyMapSequence<LazyDropWhileSequence<Base>, SegmentOfResult>>> where SegmentOfResult : Sequence

Discussion

Use this method to receive a single-level sequence when your transformation produces a sequence or collection for each element. Calling flatMap(_:) on a sequence s is equivalent to calling s.map(transform).joined().

Complexity: O(1)