How to merge two arrays in Swift

后端 未结 3 557
暖寄归人
暖寄归人 2020-12-12 02:50

I have two arrays.

let A = [\"91\",\"91\",\"49\"]
let B = [\"9989898909\",\"9089890890\",\"9098979896\"]

I need to merge these arrays and s

3条回答
  •  独厮守ぢ
    2020-12-12 03:10

    Zip the arrays and concatenate the results:

    let A=["91","91","49"]
    let B=["9989898909","9089890890","9098979896"]
    let zipped = zip(A, B)
    let result = zipped.map { $0.0 + " " + $0.1 }
    

提交回复
热议问题