The inline
keyword can be applied to custom accessors on a property,
if those accessors do not reference the backing field behind the property.
If you want both accessors to be inline
, you can apply inline
to the
property itself, as is shown in this snippet.
You can learn more about this in:
Tags:
xxxxxxxxxx
1
val stuff = mutableMapOf<String, String?>("something" to "This is the 'something' value")
2
inline var something: String?
3
get() = stuff["something"]
4
set(value) { stuff["something"] = value }
5
6
fun main() {
7
something = "This is different"
8
println(something)
9
}