You can also read values using take(), sending the amount of elements to take as a parameter. For example, you can consume the first three elements from a producer like this:
producer.take(3).consumeEach {
println(it)
}
Notice that take() on a ReceiveChannel<E> will return a ReceiveChannel<E> too, and because take() is an intermediate operation, the actual value of those three elements will be calculated when a terminal operation happens – in this case the terminal operation will be consumeEach().