English 中文(简体)
Go - 条件判断
  • 时间:2024-12-22

Go - Decision Making



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

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

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

Sr.No Statement & Description
1 if statement

An 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 statements

You can use one if or else if statement inside another if or else if statement(s).

4 switch statement

A switch statement allows a variable to be tested for equapty against a pst of values.

5 select statement

A select statement is similar to switch statement with difference that case statements refers to channel communications.