Syntactic Sugar
ufLang supports the following syntactic sugar:
If a for or if statement does not contain brackets, it will, by default, consider the first line following it as the block to execute:
Example:
for (<variable-declaration>; <condition>; <variable-update>)
<block> // Executes this line in the loop
<block> // Execute this line after the loopThe same behavior applies to if statements:
Example:
if (<condition>)
<block> // Executes this line if the condition is true
<block> // Executes this line anywayYou can also use the ternary operator instead of an if to assign a value:
Example:
<variable> = <condition> ? <value_if_true> : <value_if_false>;This is equivalent to the following if statement:
Example (with a classic if):
if (<condition>)
<variable> = <value_if_true>;
else
<variable> = <value_if_false>;Last updated