[swift-evolution] Extending the for loop to have multiple clauses

Brent Royal-Gordon brent at architechies.com
Wed Dec 9 15:43:48 CST 2015

>> I think it could be really nice to extend the for-loop so that it can have multiple clauses. Much like in the if-let with multiple clauses, I could imagine a for-loop with multiple clauses:
>> var cards: [(Suit,Rank)] = []
>> for x in suits, y in ranks {
>> cards.append((x,y))
>> }
> Isn’t this just
> 	for (x, y) in zip2(suits, ranks) {
> 	}
> ?

No, apparently it’s supposed to be all permutations of both types. But I too read it as syntactic sugar for a zip, which I think is a great reason not to add this syntax.

Brent Royal-Gordon

More information about the swift-evolution mailing list