mapNotNull

fun <T, R : Any> Sequence<T>.mapNotNull(transform: (T) -> R?): Sequence<R>(source)

Transforms elements on demand and skips null results, preserving source order. Repeated hasNext calls reuse the accepted result without invoking transform again. The callback is retained; exceptions propagate and non-local returns are unavailable. Nullable primitive results use their ordinary boxes before non-null scalar caching.