Если вы заглянете в Swift заголовок для _CollectionDefaultsType, вы увидите определение протокола следующим образом,
protocol _CollectionDefaultsType : SequenceType {
/// A type that represents a valid position in the collection.
///
/// Valid indices consist of the position of every element and a
/// "past the end" position that's not valid for use as a subscript.
typealias Index : ForwardIndexType
/// The position of the first element in a non-empty collection.
///
/// In an empty collection, `startIndex == endIndex`.
var startIndex: Self.Index { get }
/// The collection's "past the end" position.
///
/// `endIndex` is not a valid argument to `subscript`, and is always
/// reachable from `startIndex` by zero or more applications of
/// `successor()`.
var endIndex: Self.Index { get }
/// Returns the first element of `self`, or `nil` if `self` is empty.
var first: Self.Generator.Element? { get }
}
Если вы идете через файл Swift заголовок, вы можете увидеть определение массива следующим образом
struct Array<T> : CollectionType, SequenceType, _CollectionDefaultsType, _CollectionGeneratorDefaultsType, MutableCollectionType, Sliceable, _Sliceable, _DestructorSafeContainer {
/// The type of element stored by this `Array`.
typealias Element = T
/// Always zero, which is the index of the first element when non-empty.
var startIndex: Int { get }
/// A "past-the-end" element index; the successor of the last valid
/// subscript argument.
var endIndex: Int { get }
subscript (index: Int) -> T
/// Return a *generator* over the elements.
///
/// - Complexity: O(1).
func generate() -> IndexingGenerator<[T]>
/// A type that can represent a sub-range of an `Array`.
typealias SubSlice = ArraySlice<T>
subscript (subRange: Range<Int>) -> ArraySlice<T>
}
Поглотитель StartIndex, ENDINDEX, во-первых, являются те, которые реализуются из протокола _CollectionDefaultsType, чей тип Self.Index. Теперь, если вы посмотрите на определение метода indexOf, оно реализовано как расширение протокола с типом Self.Index.
extension CollectionType where Generator.Element : Equatable {
/// Returns the first index where `value` appears in `self` or `nil` if
/// `value` is not found.
///
/// - Complexity: O(`self.count`).
func indexOf(element: Self.Generator.Element) -> Self.Index?
}
Таким образом, индекс типа получает вывод на Int свыше двух реализации.
Кстати, если вы наберете в детскую площадку, чтобы увидеть индекс типа внутри массива, набрав Array.Index, автозаполнение показывает тип как Int,
Array.startIndex возвращает Int. таким образом, Self.Index будет выведено на int –