2.20. Go language if statement nesting

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

You can do it in the if or else if statement to embed one or more if or else if statement.

2.20.1. Grammar #

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

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

You can nest else if...else statements within the if statement in the same way

2.20.2. Example #

Nested use if Statement:

Example #

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

   /* Judging conditions */
   if a == 100 {
       /* Execute if the conditional statement is true */
       if b == 200 {
          /* Execute if the conditional statement is true */
          fmt.Printf("The value of a is 100, and the value of b is 200\\n" );
       }
   }
   fmt.Printf("The value of a is : %d\\n", a );
   fmt.Printf("The value of b is: %d\\n", b );
}

The result of the above code execution is:

The value of a is 100, and the value of b is 200
The value of a is: 100
The value of b is: 200

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.