Skip to content

Instantly share code, notes, and snippets.

@MasoudFallahpour
Created July 22, 2022 20:46
Show Gist options
  • Save MasoudFallahpour/de8db34cef46f1988ed4ae980565fe39 to your computer and use it in GitHub Desktop.
Save MasoudFallahpour/de8db34cef46f1988ed4ae980565fe39 to your computer and use it in GitHub Desktop.
import kotlin.reflect.KProperty
class Delegate {
private var value: String = ""
operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
println("${property.name} is read")
return value
}
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
println("${property.name} is written")
this.value = value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment