はSequenceType
protocolを理解しようとすると:なぜSequenceType.dropFirst(_ :)はSelfの代わりにSelf.SubSequenceを返しますか?
protocol SequenceType {
associatedtype SubSequence
@warn_unused_result func dropFirst(_ n: Int) -> Self.SubSequence
/* ... */
}
私たちが今までassociatedtype SubSequence
、なぜSelf
、SequenceType
を必要とするのはなぜ?
たとえば、 'someArray.dropFirst()'は 'Array'ではなく' ArraySlice'を返します。 –
@MartinRありがとう、今私は私の心の中でこの接続を持っています –