December 2017
Intermediate to advanced
260 pages
7h 34m
English
The apply() function simply executes the function or given block with its own reference this as the receiver and returns the same updated object.
A typical case of using apply can be:
supportActionBar?.apply { setDisplayHomeAsUpEnabled(true) setDisplayShowHomeEnabled(true) }
Which is as good as writing:
if(supportActionBar != null){ supportActionBar.setDisplayHomeAsUpEnabled(true); supportActionBar.setDisplayShowHomeEnabled(true); }
Read now
Unlock full access