operator
... {
associativity
precedence
}
Declarations
Returns a countable closed range that contains both of its bounds.
Use the closed range operator (...
) to create a closed range of any type
that conforms to the Strideable
protocol with an associated signed
integer Stride
type, such as any of the standard library's integer
types. This example creates a CountableClosedRange<Int>
from zero up to,
and including, nine.
let
singleDigits
=
0
...
9
(
singleDigits
.
contains
(
9
))
// Prints "true"
You can use sequence or collection methods on the singleDigits
range.
(
singleDigits
.
count
)
// Prints "10"
(
singleDigits
.
last
)
// Prints "9"
Parameters: minimum: The lower bound for the range. maximum: The upper bound for the range.
Declaration
func
...
<
Bound
where
Bound
:
_Strideable
&
Comparable
,
Bound
.
Stride
:
SignedInteger
>
(
minimum
:
Bound
,
maximum
:
Bound
) -
>
CountableClosedRange
<
Bound
>
Returns a closed range that contains both of its bounds.
Use the closed range operator (
...
) to create a closed range of any type that conforms to theComparable
protocol. This example creates aClosedRange<Character>
from "a" up to, and including, "z".Parameters: minimum: The lower bound for the range. maximum: The upper bound for the range.
Declaration
func
...
<
Bound
:
Comparable
>
(
minimum
:
Bound
,
maximum
:
Bound
) -
>
ClosedRange
<
Bound
>