is there an idiomatic way to enforce constraints o...
# getting-started
y
is there an idiomatic way to enforce constraints on a compile-time value? for example, say a class has
const val MAX_SIZE = 5
how can I stop compilation if
MAX_SIZE < 0
? I can put a
check(MAX_SIZE < 0)
in the
companion object
, but then it would only throw after the class is first instantiated
e
nope. perhaps a compile-time assert could come after https://youtrack.jetbrains.com/issue/KT-14652