The goods shed at the end of track 2 makes a wagon only when asked: drop, map, filter and take pull one at a time and close the shed once there are enough…
The key idea
Iterator helpers pull values one at a time, they never build a whole array
Try it in this playground
Take three from the endless Run hitung() with a take to the end: the depot is asked only as much as needed.
Compare the array way Run the same chain with array methods: every stage processes everything first.
Take the take away Without a take on hitung(), the chain never finishes: the depot stops at 40.
Use an iterator twice A second toArray() on the same iterator gives [].