first

suspend fun <E> ReceiveChannel<E>.first(): E (source)

Platform and version requirements: JVM

Returns first element.

Exceptions

NoSuchElementException -

if the channel is empty.

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

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

Platform and version requirements: JVM

Returns the first element matching the given predicate.

Exceptions

NoSuchElementException -

if no such element is found.

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