Private getter and public setter for a Kotlin property

后端 未结 3 1347
梦谈多话
梦谈多话 2020-12-05 09:17

How to make a property in Kotlin that has a private getter (or just do not have it) but has a public setter?

var status
private get

doesn\'

3条回答
  •  天命终不由人
    2020-12-05 09:54

    It's impossible at the moment in Kotlin to have a property with a setter that is more visible than the property. There's a language design issue in the issue tracker on this, feel free to watch/vote for it or share your use cases: https://youtrack.jetbrains.com/issue/KT-3110

提交回复
热议问题