setValue
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 }
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 }
© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/set-value.html