[swift-evolution] Change 'for in' expression to for [] { (item) in ... }

Robert Bennett rltbennett at icloud.com
Fri Jul 28 11:38:01 CDT 2017


Isn’t this exactly like forEach, which is already in the language?

> On Jul 28, 2017, at 12:32 PM, Jacob Williams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> This change would also make it so that for loops follow the same format as all other closures with variables.
> 
> The downside is that this would break a TON of code. I don’t think that the amount of code this breaks would be worth the consistency. And as Alex mentioned, it is possible through .forEach
> 
> 
>> On Jul 28, 2017, at 10:19 AM, Kwanghoon Choi via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Hello
>> 
>> I found someone easy mistake using for in loop statement.
>> 
>> Ex)
>> var i = 0
>> for i in 0..<10 { }
>> print(i)
>> 
>> And this user expected print(i) is “10”
>> 
>> Many experienced swift developers doesn’t misunderstand like this. But always someone is new comers, and I think this expression make misunderstand easy too.
>> 
>> So why not like this?
>> 
>> var I = 0
>> for 0..<10 { (i) in … }
>> 
>> I think this is more understandable for loop expression. 
>> 
>> Best Regards
>> 
>> - Jay Choi
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> 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


More information about the swift-evolution mailing list