Swift Tips: Zip different sized arrays

wonderland by ibenzani
func zip<Sequence1, Sequence2>(_ sequence1: Sequence1,_ sequence2: Sequence2 ) -> Zip2Sequence<Sequence1, Sequence2> where Sequence1 : Sequence, Sequence2 : Sequence
let words = ["one", "two", "three", "four"]
let numbers = [1, 2, 3]
let zippedArray = zip(words, numbers)
print(/("Count:"zippedArray))
//prints Count:3
//zippedArray --> [("one",1),("two",2),("three",3)]

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store