3 ms·
Comparator.comparingDouble returns a comparator, which is a two argument function, which is what min expects. Min can't know how your comparator is defined with
by ndriscoll 16d ago
Comparator.comparingDouble returns a comparator, which is a two argument function, which is what min expects. Min can't know how your comparator is defined without reflection to do that kind of peeking, and as you point out, that kind of peeking would cause observable differences in behavior.
min is a generic method. All it knows is it has a Stream<T> and a function taking two Ts. The only thing it can do is plug in Ts it gets from the stream.