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

 Conditional structures
 Exceptions
 Flow-control structures
 Loops



Task

Document common flow-control structures.



One common example of a flow-control structure is the    goto    construct.

Note that   Conditional Structures   and   Loop Structures   have their own articles/categories.



Related tasks

   Conditional Structures
   Loop Structures 


var func = Fn.new { |n|
    var i = 1
    while (true) {
        if (i == 1) {
            i = i + 1
            continue // jumps to next iteration
        }
        System.print(i)
        if (i == n) break // exits while loop
        i = i + 1
    }
    if (n < 3) return // exits function
    System.print(n + 1)
}
 
var fiber = Fiber.new {
    Fiber.abort("Demo error") // error occcurred, abort script
}
 
var a = [2, 3]
for (n in a) {
    func.call(n)
    if (n > 2) return // end module and hence the script as its a single module script
    var error = fiber.try() // catch any error
    System.print("Caught error: " + error)
}