如何在swift中将多字符串数组转换为字符串数组
变量名称:[[String]]=[[google]、[yahoo]、[facebook]] var convertNames:[字符串]=[] //如何将名称多字符串数组转换为convertNames字符串数组只需在名称数组上使用flatMap::即可获得所需的结果,即如何在swift中将多字符串数组转换为字符串数组,swift,multidimensional-array,Swift,Multidimensional Array,变量名称:[[String]]=[[google]、[yahoo]、[facebook]] var convertNames:[字符串]=[] //如何将名称多字符串数组转换为convertNames字符串数组只需在名称数组上使用flatMap::即可获得所需的结果,即 let names = [["google"],["yahoo"],["facebook"]] let convertNames = names.flatMap{ $0 } print(convertNames) //["go
let names = [["google"],["yahoo"],["facebook"]]
let convertNames = names.flatMap{ $0 }
print(convertNames) //["google", "yahoo", "facebook"]
有关flatMap中的详细信息:请参阅链接-