39. Introduction
Most code needs to reflect a decision-making process. A decision may be an either-or in which we process one set of statements rather than another. Another decision may be to run the same set of statements for a finite (or infinite) period.
Groovy supports a range of control-flow statements:
- The conditional statements:
-
ifandif-else switchtry-catch-finally
-
- The looping statements:
for-
for-each while
- The branching statements:
breakcontinuereturn
This section will describe the conditional and looping statements and discuss how and where the break and continue branching statements fit in.
The try-catch-finally statement will be explored in the Exceptions section.
The return statement will be explored in the Methods section and the Closures section.