Initialize variable in init block and define a setter for the variable in kotlin

前端 未结 0 529
生来不讨喜
生来不讨喜 2021-01-24 15:29

I want to write this piece of code but it doesn\'t work.

private var a: Int
    set(value) {
        field = a
        // Code
    }

init {
    a = 2
}


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题