[swift-evolution] [Pitch] Retiring `where` from for-in loops

Erica Sadun erica at ericasadun.com
Thu Jun 9 12:15:35 CDT 2016


> On Jun 8, 2016, at 10:17 PM, Sean Heber <sean at fifthace.com> wrote:
> 
> 
> On Jun 8, 2016, at 10:51 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> I saw your post on that *after* I finished sending this. Moving `where` next to the pattern, like you'd find in `catch` and switch `case`, the code would look like this:
>> 
>> for i where i % 2 == 0 in sequence {
>>     // do stuff
>> }
> 
> This is the best version yet - the placement of 'where' makes total sense and I really like it there.
> 

I really like how it aligns with case statements better. BUT I think using guard is still better because 
there's still user confusion between "does this terminate" and "does this filter".

Guard use is unambiguous.


-- E

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160609/db200c01/attachment.html>


More information about the swift-evolution mailing list