mapIndexedNotNullTo

inline suspend fun <E, R : Any, C : MutableCollection<in R>> ReceiveChannel<E>.mapIndexedNotNullTo(
    destination: C,
    transform: (index: Int, E) -> R?
): C
(source)

Platform and version requirements: JVM

Applies the given transform function to each element and its index in the original channel and appends only the non-null results to the given destination.

Parameters

transform -

function that takes the index of an element and the element itself and returns the result of the transform applied to the element.

The operation is terminal. This function consumes all elements of the original ReceiveChannel.