July 2018
Intermediate to advanced
242 pages
8h 6m
English
We can also use the run() function together with the safe ? operator to provide null safety of the object referenced by this keyword inside the run() function scope. You can see it in action in the following example of configuring the Android WebView class:
webview.settings?.run { this.javaScriptEnabled = true this.domStorageEnabled = false}
In the preceding piece of code, we are ensuring that the settings property is not null inside the run function scope and we can access it with this keyword.
Read now
Unlock full access