[swift-evolution] Passing an optional first argument to sequence(first:next:)

Max Moiseev moiseev at apple.com
Wed Aug 31 13:37:33 CDT 2016


Right… Good catch!

> On Aug 31, 2016, at 9:45 AM, Pyry Jahkola <pyry.jahkola at iki.fi> wrote:
> 
> 
>> 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