let array1 = ["Albert","Bobby"]
let array2 = ["Charles", "David"]
How do merge two array so that the out put would be ["Albert", "Charles", "Bobby", "David"]
let array1 = ["Albert","Bobby"]
let array2 = ["Charles", "David"]
How do merge two array so that the out put would be ["Albert", "Charles", "Bobby", "David"]
You can use zip
to combine your two arrays, and thereafter apply a .flatMap
to the tuple elements of the zip sequence:
let array1 = ["Albert","Bobby"]
let array2 = ["Charles", "David"]
let arrayMerged = zip(array1,array2).flatMap{ [$0.0, $0.1] }
print(arrayMerged) // ["Albert", "Charles", "Bobby", "David"]
Give this a shot
var a = ["one", "two"]
var b = ["three", "four"]
var c = a + b
print(c)