[Proposal] Add last(where:), lastIndex(where:), and lastIndex(of:) methods#773
Conversation
|
It's awesome. However I prefer a array.index(of: 10, options: .backward) |
|
I think the fact the proposal does not break current ABI / API and provides great flexibility, implementing new methods sounds like a better idea to me than modifying or adding functionality to existing ones. |
|
Neither API nor ABI are not stabilized yet. It's better to discuss about which is more preferable rather than which one won't break api. I've said I prefer less functions with arguments (with default value of course!) rather than a few dozen of similar functions which do fundamentally the same thing in different manner. |
|
@amosavian Thanks for that feedback! I added your suggestion to the "alternatives considered" section, so people should see it when the proposal eventually goes under review. |
| a.index(of: 10, options: .backwards) // 6 | ||
| ``` | ||
|
|
||
| This alternative approach matches the convention used in Foundation, such as `NSString.range(of:options:)` and `NSArray.indexOfObject(options:passingTest:)`, but in the opinion of this author, separate functions better suit the structure of the Swift standard library. |
There was a problem hiding this comment.
Parameterizing the direction is also a compile-time and run-time pessimisation.
|
This is now SE-0204. |
No description provided.