Conditional
The conditional (a.k.a. if
) is one of the most fundamental items in programming logic. Parenthesis on the if are optional. Due to this, braces are required around the code block. The rationale for this was that omitting braces can result in difficult to debug, critical bugs, as Apple has shown us[citation-needed].
Definition
The general syntax is the following:
Examples
Additionally, an arbitrary amount of else if
blocks can be supplied:
Scoping
Ifs, like all other code-blocks in Cheddar are block scoped. The condition of the if is evaluated in the parent's context, meaning the new scope will only be created, once the condition has been validated and the code-block is ready to execute.
Last updated