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:

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.

Related: min — the mirror image · sum · average — the other numeric terminals · sortBy — to rank rather than just find the extreme