If statements

未匹配的标注

If 语句根据布尔表达式的值指定两个分支的条件执行。如果表达式的计算结果为 true,则执行 if 分支,否则,如果 else 分支存在则执行。

IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .

if x > max {
    x = max
}

If 表达式的条件判断语句之前可以有一个简单语句,该语句在对条件表达式求值之前执行。

if x := f(); x  z {
    return z
} else {
    return y
}

"If" statements specify the conditional execution of two branches according to the value of a boolean expression. If the expression evaluates to true, the "if" branch is executed, otherwise, if present, the "else" branch is executed.

IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] .

if x > max {
    x = max
}

The expression may be preceded by a simple statement, which executes before the expression is evaluated.

if x := f(); x  z {
    return z
} else {
    return y
}

本文章首发在 LearnKu.com 网站上。

本译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。

原文地址:https://learnku.com/docs/go-specificatio...

译文地址:https://learnku.com/docs/go-specificatio...

上一篇 下一篇
贡献者:1
讨论数量: 0
发起讨论 只看当前版本


暂无话题~