[swift-evolution] Proposal: Remove the underscore and `in` for `for` loop

Christopher Kornher ckornher at me.com
Mon Jul 4 16:49:05 CDT 2016


> On Jul 4, 2016, at 2:39 PM, Karl Wagner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> -1. I like the underscore. If it turns out you do need the loop variable later, it's easy to see where to add it.
> 
> Karl

-1 I agree with this and doing something a specific number of  times without accessing the iteration counter is an edge case in my experience. Creating another syntax to save 4 characters for an edge case is a poor benefit/complexity tradeoff.  Ignoring with an underscore is universal in Swift and, to me at least, expressive and intuitive.

> 
> 
>> On Jul 1, 2016 at 9:38 AM, <Diego Barros via swift-evolution <mailto:swift-evolution at swift.org>> wrote:
>> 
>> When you want a simple `for` loop, for example:
>> 
>> for _ in 1...10 {
>> 
>> // do something 10 times
>> 
>> }
>> 
>> 
>> 
>> Clean-up and simplify the syntax by removing the superfluous underscore and `in`:
>> 
>> 
>> 
>> for 1...10 {
>> 
>> // do something 10 times
>> 
>> 
>> }
>> 
>> 
>> -- diego
>> _______________________________________________ swift-evolution mailing list swift-evolution at swift.org <mailto:swift-evolution at swift.org> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>_______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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


More information about the swift-evolution mailing list