[swift-evolution] Removing enumerated?

Ole Begemann ole at oleb.net
Tue Jan 31 09:19:51 CST 2017


On 31/01/2017 15:24, Chris Eidhof via swift-evolution wrote:
> There are a couple of things that keep coming up, and a couple of
> mistakes that I see people making over and over again. One of them is
> that in almost every workshop, there's someone who thinks that
> `enumerated()` returns a list of (index, element) pairs. This is only
> true for arrays. It breaks when using array slices, or any other kind of
> collection. In our workshops, I sometimes see people doing something
> like `x.reversed().enumerated()`, where `x` is an array, and somehow it
> produces behavior they don't understand.
>
> A few ways I think this could be improved:
>
> - Move enumerated to Array
> - Change enumerated to return `(Index, Iterator.Element)` (this would
> mean we at least need to move it to collection)
> - Remove enumerated
> - Keep things as is

Here are three previous discussion about this topic:

1) December 2015: [Idea] Add an (Index,	Element) sequence to CollectionType
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151221/004561.html 
and 
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151228/004626.html

2) April 2016: [Idea] Replace enumerate() with something more explicit
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160411/015074.html

3) September 2016: [Proposal draft] Introducing `indexed()`	collections
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160926/027355.html



More information about the swift-evolution mailing list