An interval over a comparable type, from a lower bound up to, and including, an upper bound.
You create instances of
ClosedRange by using the closed range operator (
You can use a
ClosedRange instance to quickly check if a value is contained in a particular range of values. For example:
Range, instances of
ClosedRange cannot represent an empty interval.
Creating a Range
Create a new range using the closed range operator (
Checking for Containment
Returns a Boolean value indicating whether the given element is contained within the range.
A half-open interval over a comparable type, from a lower bound up to, but not including, an upper bound.