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

Douglas Gregor dgregor at apple.com
Wed Dec 9 16:13:22 CST 2015


> On Dec 9, 2015, at 2:11 PM, Chris Eidhof <chris at eidhof.nl> wrote:
> 
> Exactly! Just like multiple-if-let is the same as flatMap on optionals, this is a better syntax for flatMap on arrays. 
> 
> To make it more clear that it’s a nested loop, we could also consider:
> 
> for x in xs, for y in ys {
> }
> 
> But I’m not sure if it actually is clearer. (You could totally still interpret this as a zip, rather than a flatMap).

I suspect I’ll always have a very hard time reading a comma-separated list of clauses as producing a nested iteration.


	- Doug




More information about the swift-evolution mailing list