Groovy – Decision Making
Decision-making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Sr.No. | Statements & Description |
---|---|
1 |
The general working of this statement is that first a condition is evaluated in the if statement. If the condition is true, it then executes the statements. |
2 |
The general working of this statement is that first a condition is evaluated in the if statement. If the condition is true it then executes the statements thereafter and stops before the else condition and exits out of the loop. If the condition is false it then executes the statements in the else statement block and then exits the loop. |
3 |
Sometimes there is a requirement to have multiple if statement embedded inside of each other. |
4 |
Sometimes the nested if-else statement is so common and is used so often that an easier statement was designed called the switch statement. |
5 |
It is also possible to have a nested set of switch statements. |