Closed hsoi closed 8 years ago
I'm good with this functionality, but I'm not sure about the naming. To me, it'd be more clear if the methods were named after
and before
.
In the example you use, foo.next(1)
, it's not super clear that next(1)
means "get the next element after 1". after(1)
is a bit more clear, imo.
Also, GeneratorType
already has a next()
method, so adding a next()
method directly to Array
, which contains a generator, could potentially be confusing
It's funny you mention that.
When I first wrote it I was thinking from the perspective of the argument element: relative to this element, there's a "next" and a "previous".
But then as I was writing the inline docs, look at the word choice I used to explain things: "before" and "after". When I was writing them, that was the natural way to explain it.
So yeah, good suggestion. :+1:
:+1: Big fan of the rename.
Looks good :+1:
If there's an easier way, or if I'm overlooking something obvious in the Swift standard library, please enlighten me.
I wrote this because I was implementing a
UIPageViewControllerDataSource
. I kept myUIViewController
s in an array, and given that data source's API, this was logical.