1
で直接プロパティを取得(または私は、デリゲート自体に状態を維持してください):設定と私はこのような委任に渡されたプロパティを設定し、取得したいデリゲート
class Example {
var p: String by Delegate()
}
class Delegate() {
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String {
if (prop/*.getValueSomehow()*/){ //<=== is this possible
} else {
prop./*setValueSomehow("foo")*/
return prop./*.getValueSomehow()*/ //<=== is this possible
}
}
operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: String) {
prop./*setValueSomehow(someDefaultValue)*/ //<=== is this possible
}
}