xii
06/10/2020, 12:11 AMDesmond Teo
06/10/2020, 2:41 AMMatteo Mirk
06/10/2020, 7:50 AMrequire()
inside the init block to check constraints for any class type:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/require.html
Regarding your specific question, nullability itself is handled by the compiler by means of nullable types, so your constraint could be expressed like:
class C(val a:Any?, val b:Any)
this tells the compiler that a
could be null but b
can’t. Is this of any help?xii
06/10/2020, 8:05 AMxii
06/10/2020, 8:32 AM