-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I started implementing the key alternative to the selector for the associateBy() operation, but in the process I realized the operation would be better defined as an overloaded method in the Sequence API, with a single function acting as the implementation (much like what has been done for the ComparatorFactory).
I think I ended up with a pretty decent solution, currently it's just a POC where only the associateBy() operation has been modified. I pushed it here:
https://github.com/couzic/sequency/tree/operations-as-methods
I didn't submit a pull request because of the impact it has on the docs (no breaking changes in the API though). Currently the operations are documented in their respective modules. With the new solution, the Sequence class displays its operators as methods, with all the overloaded variations.
@winterbe it would be nice if you could take a look and compare with the current solution. The two major benefits I see are:
- Improved type-safety by defining separate overloaded method signatures that are non-ambiguous (in this case,
associateBy()now either returns aMap<K, T>or aMap<K, V>, where it used to return aMap<K, T | V>) - More intuitive documentation, all operations are now directly visible as
Sequencemethods
Anyway, if you agree with the overall direction this is taking, I'll migrate all the operators until the documentation is consistent, then submit a pull request.