Append item to array

 Problem

I want to append an item to an existing Array.



 Recipe


// Initialize the Array
var a = [1,2,3]

// Append another item - solution A
a += [4]

// Append another item - solution B
a.append(5)

print(a)
		
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground