> On Dec 29, 2015, at 8:06 AM, Wallacy via swift-evolution
> wrote:
>
> I believe that the current behavior was thought when Slices had indices
> starting with zero.
The current behavior was intentional (and intentionally left as-is when array
slices changed);
FWIW: In cases like this, just remember call ".reverse()" and remove from
the back.
var array = [ "", "a", "b", "c", "", "d" ]
for (index, element) in array.enumerate().reverse() {
if element == "" {
array.removeAtIndex(index)
}
}
print(array) // ["a", "b", "c", "d"]
zip is
The original example contains a bug which is present on all looping
version/alternative due to the mutating nature of the array. Using the zip
implementation:
var array = [ "", "a", "b", "c", "", "d" ]
var secondHalf = array[array.count/2..
What you describe isn't a bug in the implementation, it's a bug in the
expectation that you can mutate an array that you're iterating over.
With any other collection, the mutation would actually invalidate the
index. It so happens that Arrays use Int as their index, so they can't
really be
What you're asking for can already be done with `zip(col.indices, col)`.
And in my experience the need for this sort of thing is rare enough that
there's no need to have a dedicated property for it in the stdlib. The
few times that I've needed this sort of thing, I've always just said
for index
> What you're asking for can already be done with `zip(col.indices, col)`. And
> in my experience the need for this sort of thing is rare enough that there's
> no need to have a dedicated property for it in the stdlib. The few times that
> I've needed this sort of thing, I've always just said
>