January 2018
Intermediate to advanced
434 pages
14h 1m
English
Now, let's dive in and learn how to create our own delegates:
class SingleInitializableProperty<T>() : ReadWriteProperty<Any?, T>{ private var value: T? = null override fun getValue(thisRef: Any?, property: KProperty<*>): T { if(value==null){ throw IllegalStateException("Variable not initialized") }else { return value!! } } override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { if(this.value==null){ this.value=value
Read now
Unlock full access