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); }