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.



 
show_if_with_parenthesis = fn (Num) {
    if (Num == 1) {
        io.format("is one~n")
    }
    else if (Num === 2) {
        io.format("is two~n")
    }
    else {
        io.format("not one not two~n")
    }
}
 
show_if_without_parenthesis = fn (Num) {
    if Num == 1 {
        io.format("is one~n")
    }
    else if Num === 2 {
        io.format("is two~n")
    }
    else {
        io.format("not one not two~n")
    }
}
 
show_switch_with_parenthesis = fn (Num) {
    switch (Num) {
        case (1) {
            io.format("one!~n")
        }
        case (2) {
            io.format("two!~n")
        }
        else {
            io.format("else~n")
        }
    }
}
 
show_switch_without_parenthesis = fn (Num) {
    switch (Num) {
        case 1 {
            io.format("one!~n")
        }
        case 2 {
            io.format("two!~n")
        }
        else {
            io.format("else~n")
        }
    }
}
 
@public
run = fn () {
    show_if_with_parenthesis(random.uniform(3))
    show_if_without_parenthesis(random.uniform(3))
 
    show_switch_with_parenthesis(random.uniform(3))
    show_switch_without_parenthesis(random.uniform(3))
}