Delegate

class Delegate

A simple demonstration class for a delegated property.

This class implements the getValue and setValue operator functions, allowing its instances to be used as delegates for var properties of type String.

Example of usage:

class Example {
var p: String by Delegate()
}

val e = Example()
println(e.p) // Prints: "Example@..., thank you for delegating 'p' to me"
e.p = "NEW" // Prints: "NEW has been assigned to 'p' in Example@..."

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
operator fun getValue(thisRef: Any?, property: KProperty<*>): String

Retrieves the value of the property. This is the standard getValue operator function for a property delegate.

Link copied to clipboard
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: String)

Sets the value of the property and prints a message to the standard output.