singleOrNull

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

Platform and version requirements: JVM

Returns single element, or null 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>.singleOrNull(
    predicate: (E) -> Boolean
): E?
(source)

Platform and version requirements: JVM

Returns the single element matching the given predicate, or null if element was not found or more than one element was found.

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