setValue

Common
JVM
JS
Native
1.4
operator fun <V> KMutableProperty0<V>.setValue(
    thisRef: Any?,
    property: KProperty<*>,
    value: V)

An extension operator that allows delegating a mutable property of type V to a property reference to a mutable property of the same type V.

Receiver

A property reference to a mutable property of type V. The reference is without a receiver, i.e. it either references a top-level property or has the receiver bound to it.

Example:

class Login(val username: String, var incorrectAttemptCounter: Int = 0)
val defaultLogin = Login("Admin")
var defaultLoginAttempts by defaultLogin::incorrectAttemptCounter
// equivalent to
var defaultLoginAttempts: Int
    get() = defaultLogin.incorrectAttemptCounter
    set(value) { defaultLogin.incorrectAttemptCounter = value }

Common
JVM
JS
Native
1.4
operator fun <T, V> KMutableProperty1<T, V>.setValue(
    thisRef: T,
    property: KProperty<*>,
    value: V)

An extension operator that allows delegating a mutable member or extension property of type V to a property reference to a member or extension mutable property of the same type V.

Receiver

A property reference to a read-only or mutable property of type V or its subtype. The reference has an unbound receiver of type T.

Example:

class Login(val username: String, var incorrectAttemptCounter: Int)
var Login.attempts by Login::incorrectAttemptCounter
// equivalent to
var Login.attempts: Int
    get() = this.incorrectAttemptCounter
    set(value) { this.incorrectAttemptCounter = value }