Normally a program is executed line by line in the order the code is written. Sometimes based on a certain condition, we may wan’t to break the usual flow. To do so, we have following constructs in Kotlin :
if-else
, if-else-if
, when
repeat
, for
, while
, do-while
Let us understand each of these control flow statements one by one.