{
print("Hello there.");
print("Glad to meet you.");
print("So long!");
}
if (condition) exp1
if ($x > 5)
print("It's more than 5!");
if ($x > 5) {
print("It's more than 5!");
$x = 0;
$y++;
}
与大多数语言不同,在 MEL 中,块内的所有语句(由大括号围绕)都必须以分号结束,即使是块中唯一的语句。
if ($s > 10) {print("Glonk!")} // Syntax error.
if ($s > 10) {print("Glunk!");} // Notice the semicolon.
块也可以用于限制变量的范围,因为块中声明的任何局部变量仅在该块内可见:
int $test = 10;
{
int $test = 15;
print($test+"\n");
}
print($test+"\n");
// Result:
15
10