Swift 可数范围和x27之间的区别是什么;什么是startIndex和lowerBound?

Swift 可数范围和x27之间的区别是什么;什么是startIndex和lowerBound?,swift,collections,range,Swift,Collections,Range,: 关联的绑定类型是CountableRange的元素类型和索引类型。范围的每个元素都是它自己相应的索引。CountableRange实例的下限是它的开始索引,上限是它的结束索引 var lowerBound:Bound{get}已声明 var lowerBound: Bound The range's lower bound. In an empty range, lowerBound is equal to upperBound. Declaration var lowerBound:

:

关联的绑定类型是CountableRange的元素类型和索引类型。范围的每个元素都是它自己相应的索引。CountableRange实例的下限是它的开始索引,上限是它的结束索引

var lowerBound:Bound{get}
已声明

var lowerBound: Bound
The range's lower bound.

In an empty range, lowerBound is equal to upperBound.

Declaration
var lowerBound: Bound { get }
var startIndex: Bound
The position of the first element in a nonempty collection.

If the collection is empty, startIndex is equal to endIndex.

Declaration
var startIndex: Bound { get }
var startIndex:Bound{get}
已声明

var lowerBound: Bound
The range's lower bound.

In an empty range, lowerBound is equal to upperBound.

Declaration
var lowerBound: Bound { get }
var startIndex: Bound
The position of the first element in a nonempty collection.

If the collection is empty, startIndex is equal to endIndex.

Declaration
var startIndex: Bound { get }

这两者之间有什么区别吗?我如何决定使用哪一个?

下限
起始索引
对于
可数范围
是完全等效的,正如文档中所述的
上限
结束索引

CountableRange实例的下限是它的开始索引,上限是它的结束索引


CountableRange
提供这两个属性的唯一原因是while(即:CountableRange、CountableClosedRange等)。

没有区别,因为它说CountableRange实例的下限是它的开始索引使用源:
public var startIndex:Index{return lowerBound}
请注意,如果标准库直接使用
CountableRange
下标
故意含糊不清,则不需要直接使用
startIndex
endIndex
属性。它们只适用于将范围视为通用集合的情况。