News for hackers. Stuff that matters.
Re:Swift 3.0 Release Process by lukeholder on Saturday May 07, 2016 @04:27AM (#11648844)
You have access to the index in a for-in:

for (index, element) in list.enumerate() { print("Item \(index): \(element)") }

Re:Swift 3.0 Release Process by stevetrewick on Saturday May 07, 2016 @07:04AM (#11649127)
Nitpick: for...in is not providing access to the index, it's the enumerate() method returning a collection of tuples, the first element of which happens to be an index.
Re:Swift 3.0 Release Process by jathu on Saturday May 07, 2016 @07:10AM (#11649144)
for-in is elegant, and you can use enumerate() to access index. However, if we had to do reverse for-loops in Swift 3, we would have to use for-in with either from.stride(to:by:) or reverse(), and to me that is not as elegant as c style for loops.
Re:Swift 3.0 Release Process by masklinn on Saturday May 07, 2016 @10:47AM (#11649773)
Interesting, it feels significantly more elegant to me as you're simply telling the language what you want (reverse iteration) and it handles the exact details, and works for any reversible iterable.