zip3
Three iterables walked side by side — zip with one more input.
Lecture
zip3 is zip with a third
iterable. Everything the zip page
explains holds unchanged — one record per step, laziness, and stopping
the moment any input runs out, so the result is as long as the
shortest of the three. The element type is a Dart record
(A, B, C), so destructure it by pattern matching rather than
by index.
It exists as its own function because Dart has no variadic generics: a
single zip taking a list of iterables would have to erase
the per-input types, and (A, B, C) is exactly what makes the
result worth having. The same reason tee
is joined by tee3.
One asymmetry to know: zip has a chain method
(fx(a).zip(b)) and zip3 does not — a chain has
one receiver and zip3 needs three peers. Call it as a
top-level function and wrap the result in fx() to carry on,
as the demo's last line does. zip3Async is the async form,
and like zipAsync it issues all three next()
calls before awaiting any of them, so the sources are pulled in parallel
per record rather than one after another.