9.23. Swift Fallthrough statement

发布时间 : 2025-10-25 13:33:47 UTC      

Page Views: 10 views

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 
《地理信息系统原理、技术与方法》  97

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