2.19. Go language if…else statement

发布时间 :2023-10-12 23:00:09 UTC      

if statement, you can use the optional else statement, else expression in the statement is the Boolean expression false when it is executed.

2.19.1. Grammar #

In programming Go language the syntax of the if...else statement is as follows:

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

When If is in a Boolean expression of true , the block of statements immediately following the execution of the false then execute `` else``sentence block.

The flow chart is as follows:

Image0

2.19.2. Example #

Use if else to judge the size of a number:

Example #

package main
import "fmt"
func main() {
   /* Definition of Local Variables */
   var a int = 100;

   /* Judging Boolean Expressions */
   if a < 20 {
       /* If the condition is true, execute the following statement */
       fmt.Printf("A less than 20\\n" );
   } else {
       /* If the condition is false, execute the following statement */
       fmt.Printf("A not less than 20\\n" );
   }
   fmt.Printf("The value of a is: %d\\n", a);
}

The result of the above code execution is:

A not less than 20
The value of a is: 100

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.