Instance Methodswift 6.0.3Swift

compactMap(_:)

Returns the non-nil results of mapping the given transformation over this sequence.

func compactMap<ElementOfResult>(_ transform: @escaping (Self.Elements.Element) -> ElementOfResult?) -> LazyMapSequence<LazyFilterSequence<LazyMapSequence<Self.Elements, ElementOfResult?>>, ElementOfResult>

Parameters

transform

A closure that accepts an element of this sequence as its argument and returns an optional value.

Use this method to receive a sequence of non-optional values when your transformation produces an optional value.