https://kotlinlang.org logo
#announcements
Title
# announcements
a

adams2

12/07/2017, 7:10 PM
does the initialization call my custom setter?
a

adam-mcneilly

12/07/2017, 7:18 PM
Copy code
class Test(value: Int) {
    var myValue: Int = value
    	set(value) {
            println("Setting value $value")
            field = value
        }
}

fun main(args: Array<String>) {
    val test = Test(1)
    test.myValue = 2
}
This will only print out "2". You'll never see the 1 (initial value) printed.
3 Views