How can I interleave two arrays?

前端 未结 4 1206
予麋鹿
予麋鹿 2020-11-29 12:20

If I have two arrays e.g

let one = [1,3,5]
let two = [2,4,6]

I would like to merge/interleave the arrays in the following pattern [one[0],

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 12:53

    If you're just looking to interleave two arrays, you could just do something like:

    let maxIndex = max(one.count, two.count)
    var mergedArray = Array()
    for index in 0..

提交回复
热议问题