2014-09-02 89 views
0

序列類型斯威夫特實現_Sequence_Type但是這兩個協議似乎基本上是相同的。爲什麼這樣實施?序列類型實現

protocol SequenceType : _Sequence_Type { 
    typealias Generator : GeneratorType 
    func generate() -> Generator 
} 

protocol _SequenceType { 
} 

protocol _Sequence_Type : _SequenceType { 

    /// A type whose instances can produce the elements of this 
    /// sequence, in order. 
    typealias Generator : GeneratorType 

    /// Return a generator over the elements of this sequence. The 
    /// generator's next element is the first element of the sequence. 
    func generate() -> Generator 
} 

回答

3

具有前導下劃線的協議是Apple專用的。他們的標題通常不包含他們所有的實際方法。你可以通過聲明一個類來實現它們來反向設計他們的實際方法,並且看看編譯器說的什麼缺失。 (結果當然完全不受支持,並且很可能在兩個發佈之間改變,這就是爲什麼特定協議可能是私有的。)

總之,答案是「因爲我們實際上並不知道這些協議中的內容「。