I need change it to more clear. Do you have some g...
# getting-started
l
I need change it to more clear. Do you have some good examples of property extension?
k
I recently did this:
Copy code
inline val Long.sign
    get() = when {
        this > 0L -> 1
        this < 0L -> -1
        else -> 0
    }

inline val Long.abs
    get() = Math.abs(this)
Turns out something like this was added in the latest version too, but I haven't updated yet.
I don't think I've come across a use for extension `var`s yet.
l
Good. Thanks Karel. I try find some example using property extension with var. Maybe i will back to StringBuffer property extension, is more simple to understand.
🙂
b
@karelpeeters I use them for specialized dictionaries:
Copy code
inline var Map<String, MyKey>.isStarted: Boolean
    get() = this["isStarted"].booleanValue
    set(newValue: Boolean) = this["isStarted"] = MyKey(booleanValue = newValue)