You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could do equality by key rather than requiring comparators.
I think equality by key makes sense internally -- we just create the key based on the index of the item in the source -- and this is never exposed to users.
Equality by key for the user seems overall less flexible than a comparator. An upside is equality by key doesn't require lookup via a fully constructed, or partially constructed, object. A downside is that compound orderings would require encoding their fields into the key via string concatenation in a way that is lexiographically sorted as they expect.
Maybe comparators should be Optional<T> rather than <T>? Or a generic C extends Optiona<T>? As not all fields are often required for the comparator. This gives us the best of both worlds (comparator vs key) with some added type complexity.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We could do equality by key rather than requiring comparators.
I think equality by key makes sense internally -- we just create the key based on the index of the item in the source -- and this is never exposed to users.
Equality by key for the user seems overall less flexible than a comparator. An upside is equality by key doesn't require lookup via a fully constructed, or partially constructed, object. A downside is that compound orderings would require encoding their fields into the key via string concatenation in a way that is lexiographically sorted as they expect.
Maybe comparators should be
Optional<T>
rather than<T>
? Or a genericC extends Optiona<T>
? As not all fields are often required for the comparator. This gives us the best of both worlds (comparator vs key) with some added type complexity.Beta Was this translation helpful? Give feedback.
All reactions