This provides static info on whether that upper bound is inclusive. It will betrue
iff the upper bound of this protocol includes the element at its index, like ...b
and a...b
. false
indicates that the upper bound does not include that element, like ..<b
and a..<b
.
1.2.1
This patch allows all ranges to specify whether their upper bound is inclusive; in 1.2.0, upperBoundIsInclusive
was only available on RangeWithUpperBound
.
Even when an upper bound isn't explicitly specified, it's still good to acknowledge whether it's inclusive, so we know that things like myArray = [0,1,2]
can return []
validly when accessed like myArray[3...]
.
We might imagine that, given a hypothetical a..<
range, myArray[3..<]
would not validly return []
:
let myArray = [0, 1, 2]
myArray[0...] == [0, 1, 2]
myArray[1...] == [ 1, 2]
myArray[2...] == [ 2]
myArray[3...] == [ ]
myArray[0..<] == [0, 1]
myArray[1..<] == [ 1]
myArray[2..<] == [ ]
myArray[3..<] == invalid!
So, even if the range doesn't specify its upper bound, we can still gain useful knowledge by understanding whether the upper end of it is inclusive