Is this a legal use of Zip?

AFAIK, fields are usually considered an implementation detail and are not part of the API. So your code currently works and will likely continue to work for a long time, but technically it is possible that some future version of Julia changes the internals of zip and your code breaks.

I would recommend that instead of passing a zip() object, you pass a tuple of iterators and then you only zip() them once you start iterating.

N = 3
it1 = fill(1, N)
it2 = fill(2, N)

iters = (it1,it2)
# Do what you need to do with iters[i], then iterate using
for i in zip(iters...)
    # Work on i
end
1 Like