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

2016-07-05 Thread Charlie Monroe via swift-evolution
Sorry, my example should have been the other way around: var data: NSData! for 1...5 { data = self.loadSomeData() if data != nil { break // *this* can't be done with .forEach } /// Try again in next iteration } if data == nil {

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

2016-07-05 Thread Xiaodi Wu via swift-evolution
`continue` can be rewritten `return` inside `forEach`. On Tue, Jul 5, 2016 at 02:30 Charlie Monroe via swift-evolution < swift-evolution@swift.org> wrote: > Example: > > for 1...5 { > guard let data = self.loadSomeData() else { > /// Will try it several times and then report failure to the user.

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

2016-07-05 Thread Charlie Monroe via swift-evolution
Example: for 1...5 { guard let data = self.loadSomeData() else { /// Will try it several times and then report failure to the user. continue } // process data return } // Error, failed to load data even after retrying. >

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

2016-07-05 Thread Jose Cheyo Jimenez via swift-evolution
How would you build a condition to break if you are ignoring each value ? Unless you are hard coding a condition in which case I would still argue that the proposed shorthand for is less clear than `for _ in` or forEach. > On Jul 4, 2016, at 9:29 PM, Charlie Monroe

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

2016-07-04 Thread Charlie Monroe via swift-evolution
> -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 >

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

2016-07-04 Thread Christopher Kornher via swift-evolution
> On Jul 4, 2016, at 2:39 PM, Karl Wagner via swift-evolution > 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

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

2016-07-04 Thread Karl Wagner via swift-evolution
-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 > > On Jul 1, 2016 at 9:38 AM, (mailto:swift-evolution@swift.org)> wrote: > > > > > When you want a simple `for` loop, for example: > > > >

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

2016-07-04 Thread Jose Cheyo Jimenez via swift-evolution
-1 this is why we have collection.forEach{} (1...10).forEach { // do something. } > On Jul 1, 2016, at 12:38 AM, Diego Barros via swift-evolution > wrote: > > When you want a simple `for` loop, for example: > > for _ in 1...10 { > > // do something 10 times > >

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

2016-07-04 Thread Tino Heth via swift-evolution
+1 on anything that removes underscores ;-) ___ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution

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

2016-07-03 Thread Haravikk via swift-evolution
> On 2 Jul 2016, at 14:19, Anton Zhilin via swift-evolution > wrote: > > Diego Barros via swift-evolution writes: > >> for 1...10 { >> // do something 10 times >> } > > Firstly, this should be delayed to post-Swift 3. > Secondly, I tend to

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

2016-07-01 Thread Sean Heber via swift-evolution
Minor, but I think I'd be onboard as well. Once proposed (and assuming it was approved), this would likely be deferred until post Swift 3 since it’s additive. l8r Sean > On Jul 1, 2016, at 2:38 AM, Diego Barros via swift-evolution > wrote: > > When you want a

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

2016-07-01 Thread Joseph Bell via swift-evolution
+1, having to add an underscore in a X.times loop always feels contrived. On Fri, Jul 1, 2016 at 2:38 AM, Diego Barros via swift-evolution < swift-evolution@swift.org> wrote: > When you want a simple `for` loop, for example: > > for _ in 1...10 { > > // do something 10 times > > } > > > Clean-up

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

2016-07-01 Thread Adrian Zubarev via swift-evolution
Additive idea, but +1 for looping on ranges without the need on an index. --  Adrian Zubarev Sent with Airmail Am 1. Juli 2016 um 09:39:23, Diego Barros via swift-evolution (swift-evolution@swift.org) schrieb: When you want a simple `for` loop, for example: for _ in 1...10 { // do

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

2016-07-01 Thread Diego Barros via swift-evolution
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