3 ms·
> > And I'll stand by comparators being easy to get wrong, particularly when values may be null, polymorphic, etc. > Trivial key extraction does not make that
by barrkel 14y ago
> > And I'll stand by comparators being easy to get wrong, particularly when values may be null, polymorphic, etc.
> Trivial key extraction does not make that any easier: instead of being hard, hard cases become impossible.
Perhaps you missed this bit:
> > Overloads can be used for a comparator function based approach, but it should not be the first choice.
Key extraction makes trivial cases less error prone than comparators; overloads can be used to make the hard cases possible. Comparators everywhere make all cases error-prone.