Iteration on greater than two sequences at a time at Swift

A couple of days in the past, I wanted to iterate three sequences at a time. Though Swift helps the zip, permitting you to compress two clips collectively and browse totally different pairs of things, till the variadic generics attain the language, there isn’t a option to straight compress three or extra information .

Till this type of know-how speaks the language, you’ll be able to construct nested tuplets to your occasional zip-Three or zip-Four wants with out forcing an excessive amount of readability as on this instance:

]
for (value1, (value2, value3)) in zip (seq1, zip (seq2, seq3))

I believed I would go away that right here in case that might assist somebody.

Leave a Reply

Your email address will not be published. Required fields are marked *