Martin Devillers
04/17/2019, 1:57 PMrepeat
top-level function which doesn’t take the argument for the number of times that it should execute the block, essentially sugar for an infinite loop?
inline fun repeat(action: (Int) -> Unit) {
contract { callsInPlace(action) }
var index = 0
while (true) {
action(index)
index++
}
}
I’m finding that this “repeat indefinitely” pattern is starting to occur more frequently with coroutines, and it could be nice to have a nicer syntax for it.