StructureSwift5.9.0
PartialRangeThrough
A partial interval up to, and including, an upper bound.
@frozen struct PartialRangeThrough<Bound> where Bound : Comparable
You create PartialRangeThrough
instances by using the prefix closed range operator (prefix ...
).
let throughFive = ...5.0
You can use a PartialRangeThrough
instance to quickly check if a value is contained in a particular range of values. For example:
throughFive.contains(4.0) // true
throughFive.contains(5.0) // true
throughFive.contains(6.0) // false
You can use a PartialRangeThrough
instance of a collection’s indices to represent the range from the start of the collection up to, and including, the partial range’s upper bound.
let numbers = [10, 20, 30, 40, 50, 60, 70]
print(numbers[...3])
// Prints "[10, 20, 30, 40]"
Citizens in Swift
Members
Citizens in Swift
where Bound:Comparable
Conformances
protocol RangeExpression
A type that can be used to slice a collection.
Members
Features
static func ~= (Self, Self
.Bound) -> Bool Returns a Boolean value indicating whether a value is included in a range.
Citizens in Swift
where Bound:Comparable, Bound:Encodable
Conformances
protocol Encodable
A type that can encode itself to an external representation.
Members
Citizens in Swift
where Bound:Comparable, Bound:Decodable
Conformances
protocol Decodable
A type that can decode itself from an external representation.
Members
Citizens in Swift
where Bound:Comparable, Bound:Sendable
Conformances
protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.