说我有这个数组:
let iteems = declass (id: (idl as! String?)! , piecename: (namepiece as! String?)! , pieceinfo: (infopiece as! String?)! , imagepath : (image1 as! String?)!)
如何合并它们以获得:
[0, 1, 4], [2, 3]
我尝试过:
[0,2], [0,3], [1,2], [1,3], [4,2], [4,3]
但是我得到了
[0, 1, 4].zip [2, 3]
有什么想法吗?
答案 0 :(得分:4)
[0, 1, 4].product([2, 3])
应生成:
[[0, 2], [0, 3], [1, 2], [1, 3], [4, 2], [4, 3]]