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

Charlie Monroe charlie at charliemonroe.net
Mon Jul 4 23:29:18 CDT 2016


> -1 this is why we have collection.forEach{}
> 
> (1...10).forEach {
> // do something. 
> }

This is not equivalent since it doesn't allow you to break from the for loop.

> 
> On Jul 1, 2016, at 12:38 AM, Diego Barros via swift-evolution <swift-evolution at swift.org <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/20160705/62d42795/attachment.html>


More information about the swift-evolution mailing list