Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

Task

List the conditional structures offered by a programming language. See Wikipedia: conditionals for descriptions.

Common conditional structures include if-then-else and switch.

Less common are arithmetic if, ternary operator and Hash-based conditionals.

Arithmetic if allows tight control over computed gotos, which optimizers have a hard time to figure out.



void main() {
    enum int i = 5;
 
    // "static if" for various static checks:
    static if (i == 7) {
        // ...
    } else {
        //...
    }
 
    // is(T == U) checks if type T is U.
    static if (is(typeof(i) == int)) {
        // ...
    } else {
        // ...
    }
 
    // D switch is improved over C switch:
    switch (i) {
        case 0:
            break; // Silent fallthrough is forbidden.
        case 1:
            goto case; // Explicit fallthrough.
        case 2:
            // Empty cases don't require an explicit fallthrough.
        case 3:
            return;
        case 4, 5, 7: // Multiple cases.
            break;
        case 8: .. case 15: // Inclusive interval.
            goto case 3;
        default: // Default case is required.
            break;
    }
 
    enum Colors { yellow, blue, brown, green }
    immutable c = Colors.blue;
 
    // "final switch" is safer, for enums (and in future other values,
    // like Algebraic), because all cases must be present.
    // with() is handy to avoid repeating "Colors." for each case.
    final switch (c) with (Colors) {
        case yellow:        break;
        case blue:          break;
        case brown, green:  break;
        // case yellow: .. case brown: // Forbidden in final switches.
        // default: // Forbidden in final switches.
    }
}