![]()
Blocks
A block is a group of expressions that can stand in for a single expression. Blocks are surrounded by curly braces:
For example, the if statement has this form:
exp1 can be a single expression:
...or a block of expressions:
Blocks will become important when you start to use conditional and looping statements.
Very important note
In MEL, unlike most languages, all statements inside a block (surrounded by curly braces) must end in semicolons, even if it is the only statement in the block.
if ($s > 10) {print("Glonk!")} // Syntax error. if ($s > 10) {print("Glunk!");} // Notice the semicolon.Variable scope in blocks
Blocks can also be useful to limit the scope of a variable, since any local variable declared in a block is only visible inside that block: