How to detect the last iteration in a loop

There is no way, in general, to know that an iteration is done until you actually get nothing back from iterate So you need to remember two values while iterating. This is how join does it:

5 Likes