@ExperimentalCoroutinesApi fun <E : Any> ReceiveChannel<E>.onReceiveOrNull(): SelectClause1<E?> (source)

Clause for select expression of receiveOrNull suspending function that selects with the element that is received from the channel or selects with null if the channel isClosedForReceive without cause. The select invocation fails with the original close cause exception if the channel has failed.

This extension is defined only for channels on non-null types, so that generic functions defined using these extensions do not accidentally confuse null value and a normally closed channel, leading to hard to find bugs.