Swift数组元素映射
Swift array element map
我有数组 [[one, two, three, four]]
,我想在 [["one", "two"," three", "four"]]
中转换数组而不使用 Swift 中的循环 3.
我试过了
let myArray = array.map { String([=11=]) }
但这是返回 ["[one, two, three, four]"]
。
在你的例子中,你实际上有两个数组。你有一个数组的数组,无论是什么,等等。
尝试:
let result = array.map { [=10=].map { String([=10=]) } }
Array([[one, two, three, four]][0].map({String([=10=])}))
我有数组 [[one, two, three, four]]
,我想在 [["one", "two"," three", "four"]]
中转换数组而不使用 Swift 中的循环 3.
我试过了
let myArray = array.map { String([=11=]) }
但这是返回 ["[one, two, three, four]"]
。
在你的例子中,你实际上有两个数组。你有一个数组的数组,无论是什么,等等。
尝试:
let result = array.map { [=10=].map { String([=10=]) } }
Array([[one, two, three, four]][0].map({String([=10=])}))