next

abstract operator fun next(): E(source)

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:

while (iterator.hasNext()) {
val element = iterator.next()
// ... handle element ...
}

This method throws a ClosedReceiveChannelException if the channel is closed for receive without a cause. It throws the original close cause exception if the channel has failed.