How it works...
Thanks to treating OnClickListener as a function, we were able to implement it in the clean and concise form of a lambda expression. The lambda's body will globally be invoked whenever the user clicks the button. In our case, once the button is clicked, it will be hidden away.
Lambda expressions are one of the most essential functional features of the language and are used extensively in the standard library components. They can be seen as an abbreviated form of a function or a functional interface implementation. Lambdas help to organize code correctly and reduce a lot of boilerplate code. The syntax of a lambda expression can be seen as a block of code placed between { } symbols. Lambda expressions can have function arguments ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access