9.23. Swift Fallthrough statement

发布时间 :2023-12-08 01:10:06 UTC      

Swift fallthrough statement let case subsequent statements continue to run sequentially, regardless of whether the conditions are met or not.

The switch in Swift is not from the previous case the branch falls intothe next case in the branch. As long as the first match case the branch completes the statement it needs to execute, the entire switch the code block completes its execution.

Note: in most languages switch in the sentence block case keep up with it break otherwise, case subsequent statements are run sequentially, but in the Swift language, they are not executed by default switch and it will stop. If you want to let in Swift case if the subsequent statements continue to run in order, you need to use the fallthrough statement.

9.23.1. Grammar #

Swift fallthrough the syntax format of the statement is as follows:

fallthrough

Generally in switch statement does not use the fallthrough statement.

9.23.2. Example 1 #

The following examples are not used fallthrough statement:

import Cocoa

var index = 10

switch index {
   case 100  :
      print( "The value of index is 100")
   case 10,15  :
      print( "The value of index is 10 or 15")
   case 5  :
      print( "iThe value of index is 5")
   default :
      print( "default case")
}

When the above code is compiled and executed, it produces the following results:

The value of index is 10 or 15

9.23.3. Example 2 #

The following examples use the fallthrough statement:

import Cocoa

var index = 10

switch index {
   case 100  :
      print( "The value of index is 100")
      fallthrough
   case 10,15  :
      print( "The value of index is 10 or 15")
      fallthrough
   case 5  :
      print( "The value of index is 5")
   default :
      print( "default case")
}

When the above code is compiled and executed, it produces the following results:

The value of index is 10 or 15
The value of index is 5

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.