Resettable

class Resettable<T>(default: () -> T)

A property delegate that instruments resetting it between opmode runs.

This is used in delegate properties. You must pass a function when constructing the resettable property that returns its default value.

val property: Type by Resettable {
// This is a function body.
// You can run anything in here.
val x = 1 + 2

// You do not need the `return` keyword.
// The last expression in the block, will be returned.
x + 2 // will return 5
}

Example

object MyAPI : API() {
// The starting value of someState is 10
private var someState: Int by Resettable { 10 }
}

Constructors

Link copied to clipboard
constructor(default: () -> T)

Functions

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