Get the size of an array

 Problem

I have an Array and want to calculate its size/capacity (how many elements it contains).



 Recipe


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

// Get the size of the array

let size = a.count
print(size)

		
				

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