What's a possible use case for `InvocationKind.AT_...
# announcements
p
What's a possible use case for
InvocationKind.AT_MOST_ONCE
? Use case as in: What is it good for, not how to use it.
k
You can use it to avoid the "possible reassignment" error:
Copy code
fun main() {
    val bar: Int
    foo {
        bar = 5
    }
}

fun foo(block: () -> Unit) {
    contract { 
        callsInPlace(block, InvocationKind.AT_MOST_ONCE)
    }
    if (Random.Default.nextBoolean())
        block()
}
Altough I have no idea what that is useful for, it's not like you can actually use the
bar
variable afterwards because it may not be initialized.