What do you think about adding a `repeat` top-leve...
# stdlib
m
What do you think about adding a
repeat
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?
Copy code
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.