Bikeshed opportunity: compose vs composeWith (original) (raw)
Remi Forax forax at univ-mlv.fr
Mon Nov 26 15:34:39 PST 2012
- Previous message: Bikeshed opportunity: compose vs composeWith
- Next message: Bikeshed opportunity: compose vs composeWith
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 11/26/2012 11:56 PM, Brian Goetz wrote:
This would be cool to read, but is a different animal.
people.sortBy(Person::getLast).thenBy(Person::getFirst) Right. See exchange last week about the combinatorial explosion when we tried this. We use the word "chain" on our Comparators static utility class in GS Collections with varargs. But since you are adding this method to Comparator, not sure if chain or chainWith would be a good name. Seems a possibility. What about this? people.sort(comparing(Person::getLast).thenBy(Person::getFirst)) At first I thought this was "same as above", but now that I think about it more it is possible. This would involve overloading: thenBy(Comparator) with thenBy(Function<T,U extends Comparable>) thenBy(IntFunction) in Comparator. It also looks OK outside the sort example: Comparator byFirstLast = byLast.thenBy(Person::getFirst);
It's the same explosion as sortBy. so if you accept several overloads un Comparator, we should accept the several overloads of sortBy.
Rémi
- Previous message: Bikeshed opportunity: compose vs composeWith
- Next message: Bikeshed opportunity: compose vs composeWith
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list