Ranges are generic data types that represent a sequence of numbers. Let's look at the following diagram to understand this:
Ranges
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.....