2.17. Go language conditional statement

发布时间 : 2025-10-25 13:32:59 UTC      

Page Views: 9 views

Conditional statements require developers to specify one or more conditions and test whether the condition is true to decide whether to execute thespecified statement, and if the false condition is executing another statement.

The following figure shows the structure of conditional statements in a program language:

Image0

Go language provides the following conditional judgment statements:

Statement

Description

If statement

If statement? Consists of a Boolean expression followed by one or more statements.

If…else statement

If statement? You can then use the optional? else statement, where the expression in the else statement executes when the Boolean expression is false.

If nested statement

You can do it in if? Or else if? Embed one or more if in the statement. Or else if? Statement.

Switch statement

Switch? Statement is used to perform different actions based on different conditions.

Select statement

Select? The statement is similar to? switch? Statement, but select randomly executes a runnable case. If there is no case to run, it will block until case is available.

Note: Go has no ternary operator, so it is not supported ?: condition judgment of form.

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。