One could write a generic `interval` function that...
# coroutines
j
One could write a generic
interval
function that way. Calling
cancel()
on the ReceiveChannel would interrupt the for loop. So for example
interval(500).take(5).consumeEach { println(it) }
would not waste any resource, because the channel will be canceled after the 5th element.