9.20. Swift repeat…while cycle

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

Page Views: 9 views

Swift repeat...while the cycle is not like for and while the loop judges the conditional statement before the loop body starts execution,but determines whether the condition is met at the end of the loop execution.

9.20.1. Grammar #

Swift repeat...while the syntax format of the loop is as follows:

repeat { statement(s); }while( condition ); 

Notice that the conditional expression appears at the end of the loop, so the statement(s) will be executed at least once before the conditionis tested.

If the condition is true the control flow will jump back to the above repeat and then re-execute the statement(s) . This process is repeated over and over again until a given condition becomes false so far.

The number 0, the strings’0’ and’’, empty list() and undefined variables are false and the rest are true . true use it backwards! Number or not , take the reverse and return false .

Flow chart:

Image0

9.20.2. Example #

import Cocoa var index = 15 repeat{ print( "The value of index is \(index)") index = index + 1 }while index < 20 

The output of the above program execution is as follows:

The value of index is 15 The value of index is 16 The value of index is 17 The value of index is 18 The value of index is 19 
《地理信息系统原理、技术与方法》  97

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