What is a cleaner way to do this: ``` var foo: Str...
# announcements
m
What is a cleaner way to do this:
Copy code
var foo: String = "foo" // set is not invoked during initialization
    set(value) {
        print("SET $value")
        field = value
    }

init {
    foo = "foo" // have to do this in order to invoke set function
}
property with custom setter can’t be
lateinit
h
Copy code
var foo: String by Delegates.observable("foo") {
        prop, old, new ->
        println("$old -> $new")
    }
}
👍 3
u can also create your own delegation, as i dont think that runs on init
m
Didn’t think about property delegates, thanks!