elementAtOrElse

inline suspend fun <E> ReceiveChannel<E>.elementAtOrElse(
    index: Int,
    defaultValue: (Int) -> E
): E
(source)

Platform and version requirements: JVM

Returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this channel.

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