官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 沿河| 瑞丽市| 乌恰县| 聂拉木县| 东平县| 西和县| 黔东| 水富县| 通渭县| 日土县| 南部县| 安平县| 右玉县| 通州区| 临沭县| 金门县| 象州县| 佛冈县| 宿州市| 双柏县| 光泽县| 霍城县| 福安市| 方山县| 丰宁| 富川| 聂拉木县| 大关县| 庆元县| 碌曲县| 遂昌县| 珠海市| 定兴县| 瑞昌市| 永善县| 阳曲县| 津南区| 城固县| 彩票| 大姚县| 贵定县|