single

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

Platform and version requirements: JVM

Returns the single element, or throws an exception if the channel is empty or has more than one element.

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

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

Platform and version requirements: JVM

Returns the single element matching the given predicate, or throws exception if there is no or more than one matching element.

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