mplatvoet
09/30/2015, 9:31 AMBut really it doesn't make sense when combined with hard constraints. If you want a hard constraint, you wouldn't default it.To me contraints and default values are two separate concerns. The only optimisation I can think of is that you want to skip constraint validation when you use a default value which you control. On which you can use null as a default indicator, e.g.:
class Bar
data class Foo(bar: Bar? = null) {
public val bar: Bar
init {
//validate `bar`
this.bar = bar ?: Bar()
}
}