1
我試圖在斯威夫特4.自定義集合類,我實現: startIndex
,endIndex
,index(after:)
,subscript(Element)
, subscript(Range<Element>)
,並已指定類型Element
。爲什麼我得到這個錯誤?「收藏」需要的各類「MyCollectionClass.Element」和「片<MyCollectionClass>」相當於
extension MyCollectionClass: Collection {
public typealias Element = MyCollectionElement
public var startIndex: Int {
return _values.startIndex
}
public var endIndex: Int {
return _values.endIndex
}
public func index(after: Index) -> Index {
return _values.index(after: after)
}
public subscript(position: Index) -> Element {
return _values[position]
}
public subscript(bounds: Range<Index>) -> SubSequence {
return _values[bounds]
}
}
「收藏」要求類型「MyCollectionClass.Element」和「切片< MyCollectionClass>」相當於