Anyone know why i would want to use a property extension as opposed to just defining a local class extension? here is an example of a property extension that i have tried:
class MyClass {
val String.concatMyName: String
get() {
return plus("FRED")
}
}
the usage can be “my name is:“.concatMyName
but i could also do
class MyClass{
fun String.concatMyName2() = this.plus("FRED")
}
usage would be: “my name is:“.concatMyName2()
so i'm not seeing the value yet.
i thought possibly one value is that its utilizing the getter so its not having to put the static code in memory. would that be the savings only ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…