[swift-evolution] [Pitch] New collection-based 'repeat' API
Karl Wagner
razielim at gmail.com
Mon May 1 21:52:25 CDT 2017
> On 2 May 2017, at 04:44, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
> Does this gain something by being part of the standard library as opposed to being built on top of it?
Well, somebody thought repeatElement<T> was general enough to make part of the standard library. If we’re going to allow repeating a single item as a Collection, we might as well allow generalise it to repeating any Collection in a loop (including a CollectionOfOne, which is the existing use-case).
Personally, I usually want to repeat a collection of things far more often than I want to repeat an individual thing. It annoys me that the standard library only provides the one I almost never need.
Additionally, it could help remove the top-level “repeatElement” function, which I know irritates some people who would rather us not have any top-level functions in the standard library.
- Karl
More information about the swift-evolution
mailing list