Join Slack
Powered by
is there an idiomatic way to enforce constraints o...
# getting-started
y
y
05/08/2023, 2:37 PM
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
ephemient
05/08/2023, 3:41 PM
nope. perhaps a compile-time assert could come after
https://youtrack.jetbrains.com/issue/KT-14652
Open in Slack
Previous
Next