notNull

This delegate property is similar to lateinit properties. It allows a property to be declared without an initial value. If the value hasn’t been set yet and you try to read it, an exception is thrown:

var notNull by Delegates.notNull<Int>()

The value hasn't been set yet and if we try to read it, an exception will be thrown:

//this results in exception
val n = notNull

We have to assign a value to the property first:

notNull = 1
val num = notNull
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.23.4