Bikeshed opportunity: compose vs composeWith

Brian Goetz brian.goetz at oracle.com
Mon Nov 26 14:57:35 PST 2012


>> I like the "then" convention to indicate sequencing.  In context:
>>
>> people.sort(comparing(Person::getLast)
>>               .thenCompare(comparing(Person::getFirst)))
>
> or
>    people.sort(comparing(Person::getLast, Person::getFirst))
> (comparing is a static method so it can be annotated with @SafeVarargs).

This one falls apart as there is no common supertype between
   Function<Person, T extends Comparable>
and
   IntFunction<Person>

so people will try

   people.sort(comparing(Person::getLast, Person::getHeight))

and be mystified by the error message they get.  And then ask for a 
combinatorial explosion of comparing() methods.


More information about the lambda-libs-spec-observers mailing list