- iOS 12 Programming for Beginners
- Craig Clayton
- 196字
- 2021-07-02 15:04:57
Closed range
Notice that, in the preceding diagram, we have numbers ranging from 10 to 20. Rather than having to write each value, we can use ranges to represent all of these numbers in shorthand form. To do this, let's remove all of the numbers in the diagram except for 10 and 20:

Now that we have removed those numbers, we need a way to tell Swift that we want to include all of the numbers that we just deleted. All the numbers in-between are where the range operator (...) comes into play. Therefore, in Playgrounds, let's create a constant called range and set it equal to 10...20:
let range = 10...20
You should see the following:

The range that we just entered says that we want the numbers between 10 and 20, as well as both 10 and 20 themselves. This type of range is known as a closed range.
Inside Playground, in the result, you will see a Show Result icon:

If you hover over the result, you will also see quick look:

Select the Show Result icon so that you can see the result:

We also have what is called a half-closed range.
- OpenLayers Cookbook
- Building RESTful Web Services with Spring 5(Second Edition)
- PLC、現(xiàn)場總線及工業(yè)網(wǎng)絡(luò)實用技術(shù)速成
- Mastering TypeScript 3
- Building RESTful Web services with Go
- OMNeT++與網(wǎng)絡(luò)仿真
- 光纖通信系統(tǒng)與網(wǎng)絡(luò)(修訂版)
- 網(wǎng)管工具使用與技巧大全
- jQuery Mobile Web Development Essentials
- 異構(gòu)蜂窩網(wǎng)絡(luò)關(guān)鍵理論與技術(shù)
- 路由與交換技術(shù)
- Telerik WPF Controls Tutorial
- Scala Programming Projects
- 物聯(lián)網(wǎng)系統(tǒng)設(shè)計
- 5G時代:生活方式和商業(yè)模式的大變革