Is there a way to use the new Kotlin contracts alo...
# android
y
Is there a way to use the new Kotlin contracts along with an API check? For example, I want to turn the following:
Copy code
if (Build.VERSION.SDK_INT >= 23) {
    // Long code block
} else {
    throw IllegalAccessException()
}
Into:
Copy code
if (Build.VERSION.SDK_INT < 23) throw IllegalAccessException()
// Long code block
g
But this constant is known only on runtime, so I cannot imagine any contract for this code
Ahhh, sorry, I see what you mean
To let compiler know that this check already passed? Anyway don't think that it is possible
y
Yeah, just to avoid the extra indents. I know it's picky, just curious
l
I'd submit this feature request on kotl.in/issue and link it back here