- iOS 12 Programming for Beginners
- Craig Clayton
- 141字
- 2021-07-02 15:04:58
One-sided range
A one-sided range operator allows you to use ranges that continue as far as possible in one direction. If you want the range to continue, then this is what you would use. Let's look at a one-sided range by adding the following:
let names = ["Craig", "Teena", "Jason", "Joshua", "Myah", "Tiffany", "Kim", "Veronica", "Mikki(KK)", "Milan", "Shelby", "Kaysey"]
for name in names[2...] {
print(name)
}
You will see that all the names print in the console:

As a next step, let's add the following:
for name in names[...6] { print(name) } // Craig // Teena
// Jason // Joshua // Myah // Tiffany // Kim
You should now see in the console how this update changes what is in the console:

Another useful loop is the while loop. Let's take a look at how the while loop is used.
推薦閱讀
- 黑客攻防實戰(zhàn)技術(shù)完全手冊:掃描、嗅探、入侵與防御
- 物聯(lián)網(wǎng)安全(原書第2版)
- Truffle Quick Start Guide
- 5G承載網(wǎng)網(wǎng)絡(luò)規(guī)劃與組網(wǎng)設(shè)計
- 走進(jìn)物聯(lián)網(wǎng)
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- 大話社交網(wǎng)絡(luò)
- 物聯(lián)網(wǎng)通信技術(shù)
- IPv6網(wǎng)絡(luò)切片:使能千行百業(yè)新體驗
- 2小時讀懂物聯(lián)網(wǎng)
- The Kubernetes Workshop
- 端到端QoS網(wǎng)絡(luò)設(shè)計
- 深入理解Nginx:模塊開發(fā)與架構(gòu)解析
- 組網(wǎng)技術(shù)與網(wǎng)絡(luò)管理
- 移動互聯(lián)網(wǎng)新思維