[swift-evolution] Passing an optional first argument to sequence(first:next:)
Pyry Jahkola
pyry.jahkola at iki.fi
Wed Aug 31 11:45:10 CDT 2016
> Max Moiseev wrote:
>
> FWIW, the ‘classical’ way of doing what I think you’re trying to do is:
>
> extension Sequence {
> var pairs: AnySequence<(Iterator.Element, Iterator.Element)> {
> return AnySequence(zip(self, self.dropFirst()))
> }
> }
>
> Does it have the right behavior?
It doesn't if the sequence is single-pass or if iterating over it multiple times has other unwanted side-effects.
— Pyry
More information about the swift-evolution
mailing list