you will need a while loop if a continue is not su...
# getting-started
s
you will need a while loop if a continue is not sufficient 😛
b
I couldn’t even think of a legit use case, so I just made one up LOL but I’m going to put this here, hopefully to never to be used lol
Copy code
inline fun forEachJumpable(start: Int, endInclusive: Int, block: (Int, (Int) -> Int) -> Unit) {
    var i = start
    if (start > endInclusive) return
    while (i <= endInclusive) {
        var changed = false
        block(i) {
            i += it
            changed = true
            i
        }
        if (!changed) i++
    }
}

fun foo() {
        // prints: 1 3 6 7 12 13 14 15
        forEachJumpable(1, 16) { i, jump ->
            if (i % 2 == 0) {
                jump(i / 2)
            } else {
                print("$i ")
            }
        }
}
s
wow
not bad
also good god I hope nobody actually does that lmao