Swift in Depth ⟩ Ch 9: Iterators, sequences, and collectionsarrow-up-right
Swift ⟩
IteratorProtocolarrow-up-right
IndexingIterator<Element>arrow-up-right - [Element].makeIteratorarrow-up-right() 回傳的 iterator
SwiftDoc ⟩ IteratorProtocolarrow-up-right
具有 next() 方法的物件就可遵循 IteratorProtocolarrow-up-right,也就是一個 iterator。
類似 JS 的 iterator protocol。
public protocol IteratorProtocol { associatedtype Element mutating func next() -> Element? }
Last updated 4 years ago