2014-09-02 79 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专用的。他们的标题通常不包含他们所有的实际方法。你可以通过声明一个类来实现它们来反向设计他们的实际方法,并且看看编译器说的什么缺失。 (结果当然完全不受支持,并且很可能在两个发布之间改变,这就是为什么特定协议可能是私有的。)

总之,答案是“因为我们实际上并不知道这些协议中的内容“。