📜  Go语言-决策

📅  最后修改于: 2020-11-04 08:03:12             🧑  作者: Mango


 

决策结构要求程序员指定一个或多个要由程序评估或测试的条件,以及确定条件为真的情况下要执行的一条或多条语句,以及如果条件被确定为可选的其他执行语句确定为假。

以下是大多数编程语言中常见的典型决策结构的一般形式-

Go中的决策声明

Go编程语言提供以下类型的决策声明。单击以下链接以查看其详细信息。

Sr.No Statement & Description
1 if statementAn if statement consists of a boolean expression followed by one or more statements.
2 if…else statement

An if statement can be followed by an optional else statement, which executes when the boolean expression is false.

3 nested if statementsYou can use one if or else if statement inside another if or else if statement(s).
4 switch statementA switch statement allows a variable to be tested for equality against a list of values.
5 select statementA select statement is similar to switch statement with difference that case statements refers to channel communications.