append array to array swift code example
Example 1: swift append element to array
anArray.append("This String")
anArray += ["Moar", "Strings"]
anArray.append(contentsOf: ["Moar", "Strings"])
anArray.insert("This String", at: 0)
anArray.insert(contentsOf: ["Moar", "Strings"], at: 0)
Example 2: join arrays swift
let array1 = [1, 2, 3]
let array2 = [4, 5, 6]
let array3 = array1 + array2
print(array3)
Example 3: swift append to array
var numbers = [1, 2, 3, 4, 5]
numbers.append(100)
print(numbers)
Example 4: swift add two arrays
let c = [a, b].lazy.flatten()