mapToFirstNotNullOf

inline fun <T, R : Any> Iterable<T>.mapToFirstNotNullOf(transform: (T) -> R?): Pair<T, R>

Locates the first element T from this Iterable that, when passed to the transform lambda, produces a non-null value R, returning the Pair T to R.

This function is similar to firstNotNullOf, but also includes the element that produces the non-null result.

Return

A pair containing the producing element and its transformation result of the first non-null value produced by transform

Parameters

T

The type of elements in this Iterable

R

The type of the transformation result

transform

A function that transforms an element T to a nullable result R

Throws

NoSuchElementException

if no transformation produces a non-null result