上QQ阅读APP看书,第一时间看更新
Half-closed range
Let's make another constant that is known as a half-closed range and set it equal to 10 < 20. Add the following to Playgrounds:
let halfClosedRange = 10..<20
Your code should now look like this:
A half-closed range is the same as a closed range, except that the end value is not included. In this example, this means that 10 through 19 are included, and 20 will be excluded.
At this point, you will notice that your Results Panel shows you CountableClosedRange(10...20) and CountableRange(10..<20). We cannot see all of the numbers within the range. To see all of the numbers, we need to use a loop.