MutableMap.MutableEntry.setValue


#1

kotlin.collections.Map.Entry defines val value: V.

kotlin.collections.MutableMap.MutableEntry defines fun setValue(newValue: V): V.

Why have fun setValue(newValue: V): V when val value: V can be overridden with override var value: V?

Is it too late to change this? e.g.

from

public interface MutableEntry<K, V> : kotlin.collections.Map.Entry<K, V> {
    public abstract fun setValue(newValue: V): V
}

to

public interface MutableEntry<K, V> : kotlin.collections.Map.Entry<K, V> {
    public abstract override var value: V
    @Deprecated("use value var override instead", ReplaceWith("value"))
    public abstract fun setValue(newValue: V): V
}

#2

setValue returns old value of map entry, that’s why it can’t be just setter.


#3

Wow… I even wrote that but completely overlooked it. Thank you.