So, I have an interesting problem. This does not w...
# announcements
r
So, I have an interesting problem. This does not work, because
value
is not initialized. What is the correct way to do this?
Copy code
class Validated(val validator: Validator, default: Any) {
    var value: Any
        set(value) {
            if (!validator.valid(value)) error("invalid")
            field = value
        }

    init {
        value = default
    }
}