© Peter Späth 2019
Peter SpäthLearn Kotlin for Android Developmenthttps://doi.org/10.1007/978-1-4842-4467-8_7

7.  Structural Constructs

Peter Späth1 
(1)
Leipzig, Germany
 

From the very beginning of computer languages, conditional branching of the program flow has been one of the most basic things program code must be able to express. This branching happens inside functions, so it imposes some kind of substructuring inside classes and singleton objects. In this chapter we cover such branching constructs, together with auxiliary classes that help us write corresponding code.

Ifs and Whens

In real life many actions are based on decisions. If some condition is met, an action A happens; otherwise, action B happens. For any programming language we need ...

Get Learn Kotlin for Android Development: The Next Generation Language for Modern Android Apps Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.