2.18. Go language if statement

发布时间 :2023-12-11 00:55:03 UTC      

if statement consists of a Boolean expression followed by one or more statements.

2.18.1. Grammar #

The syntax of the if statement in Go programming language is as follows:

If Boolean expression {
   /* Execute when Boolean expression is true */
}

When If is in a Boolean expression of true , the statement block immediately following is executed, and if it is false , it is not executed.

The flow chart is as follows:

Image0

2.18.2. Example #

Use if to determine the size of a numeric variable:

Example #

package main
import "fmt"
func main() {
   /* Define local variables */
   var a int = 10

   /* Using an if statement to determine a Boolean expression */
   if a < 20 {
       /* If the condition is true, execute the following statement */
       fmt.Printf("A less than 20\\n" )
   }
   fmt.Printf("The value of a is : %d\\n", a)
}

The result of the above code execution is:

A less than 20
The value of a is: 10

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.