guys. I'm new in Kotlin and I'm trying to figure out how to use getters and setters in Kotlin. In java I need to write getters on my own(generate by ide) or use Annotations like @Getter in lombok, which was pretty simple. Kotlin however has getters and setters by default. https://kotlinlang.org/docs/reference/properties.html But I can't understand how to use it.
I want to make it, lets say - similar to java:
private val isEmpty: String
get() = this.toString() //making this thing public rises an error: Getter visibility must be the same as property visibility.
So how getters work?
Aucun commentaire:
Enregistrer un commentaire