firstOrNull

suspend fun <E> ReceiveChannel<E>.firstOrNull(): E? (source)

Platform and version requirements: JVM

Returns the first element, or null if the channel is empty.

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

inline suspend fun <E> ReceiveChannel<E>.firstOrNull(
    predicate: (E) -> Boolean
): E?
(source)

Platform and version requirements: JVM

Returns the first element matching the given predicate, or null if element was not found.

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