ChannelIterator

interface ChannelIterator<out E>(source)

Iterator for ReceiveChannel. Instances of this interface are not thread-safe and shall not be used from concurrent coroutines.

Functions

Link copied to clipboard
abstract suspend operator fun hasNext(): Boolean

Returns true if the channel has more elements, suspending the caller while this channel is empty, or returns false if the channel is closed for receive without a cause. It throws the original close cause exception if the channel has failed.

Link copied to clipboard
abstract operator fun next(): E

Retrieves the element removed from the channel by a preceding call to hasNext, or throws an IllegalStateException if hasNext was not invoked. This method should only be used in pair with hasNext: