LPC has the same control flow statements as C (and one addition
do-whileloop where the loop body is at least executed once and the condition is evaluated first after the first loop.
forloops contain three expressions and a loop body. The first expression is executed at the beginning of the loop. The second expression is evaluated each time before the loop body is executed. If this expression yields zero then the loop will end. The third expression is executed at the end of each loop.
foreachiterates over a range, which can be an array, mapping, struct (iterating over each member variable), string (iterating over each character of the string), or an integer range.
switchexecutes code blocks depending on a value. When there is no
breakstatement at the end of a
caseblock then the following block is executed as well.
breakexits the innermost
continuewill continue the execution from the beginning of the innermost
foreachloop. In a
forloop the third expression (loop end) and second expression (loop condition) are evaluated. If the loop condition yields zero, the loop ends. Similarly the loop condition of
whileis evaluated. In
foreachloops the loop starts with the next value.
returnexits the current function and optionally returns a value.