The more idiomatic way is to look at API design in a new way. Note these
points:

1. `Countable` variant is preferred when you want to deal with integer
ranges as it more closely matches the element type.
2. Both countable range variants share a common protocol conformance
already: `RandomAccessCollection`
3. Swift API design prefers member functions to free functions.

Hence a more idiomatic (Swifty) API would probably be something like this:

Thanks for sharing this solution, Hooman, I really like it. I think you're making a great point about considering the appropriate abstraction for an algorithm, which is why I blogged about this: https://oleb.net/blog/2016/10/generic-range-algorithms/

I hope you don't mind.

Ole

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to