Open
Description
Please, see explicit-backing-fields.md for the full text in PR #289.
Summary
Sometimes, Kotlin programmers need to declare two properties which are conceptually the same, but one is part of a public API and another is an implementation detail. This is known as backing properties:
class C {
private val _elementList = mutableListOf<Element>()
val elementList: List<Element>
get() = _elementList
}
With the proposed syntax in mind, the above code snippet could be rewritten as follows:
class C {
val elementList: List<Element>
field = mutableListOf()
}
Metadata
Metadata
Assignees
Labels
No labels