But even better to define it as suspending functio...
# coroutines
e
But even better to define it as suspending function (that is how it is going to be):
Copy code
suspend fun <T> ReceiveChannel<T>.toList(): List<T> =
    ArrayList<T>().also { list ->
        consumeEach { list.add(it) }
    }