max
The largest number in the pipeline — the mirror image of min.
num max(Iterable<num> iterable)
Future<num> maxAsync(FxAsyncIterable<num> iterable)
num Fx<num>.max() // chain (sync)
Future<num> FxAsync<num>.max() // chain (async)
Lecture
max works exactly like min,
flipped: it's fold(-double.infinity, ..., iterable), keeping
the largest value seen so far.
The same two FxTS-faithful quirks apply, just mirrored:
- An empty iterable returns
-double.infinity, notnull. - A single
NaNanywhere poisons the result toNaN— same reasoning asmin: every comparison againstNaNis false.
As with the other numeric terminals, the chain form
(Fx<num>.max() / FxAsync<num>.max())
is only available when the compiler knows your chain holds numbers.
Demo 1 · Basics, empty, and NaN
Demo 2 · Async
Try it yourself
Exercise: find the highest temperature in the list.