take

fun <E> ReceiveChannel<E>.take(
    n: Int,
    context: CoroutineContext = Unconfined
): ReceiveChannel<E>
(source)

Platform and version requirements: JVM

Returns a channel containing first n elements.

The operation is intermediate and stateless. This function consumes all elements of the original ReceiveChannel.