您如何迭代 Swift 中 Zip2 产生的值
How do you iterate over values resulting from Zip2 in Swift
我想使用 for-in 循环。
其实很简单。只需使用 Array(Zip2)
。之后你可以迭代它:
let theZip = Zip2(["Hi", "up?", "that"], ["whats", "Not", "much"])
let myZipArray = Array(theZip)
//without array
for single in theZip{
println(single)
}
//with array
for single2 in myZipArray{
println(single2)
}
我想使用 for-in 循环。
其实很简单。只需使用 Array(Zip2)
。之后你可以迭代它:
let theZip = Zip2(["Hi", "up?", "that"], ["whats", "Not", "much"])
let myZipArray = Array(theZip)
//without array
for single in theZip{
println(single)
}
//with array
for single2 in myZipArray{
println(single2)
}