Check if array is empty

 Problem

I want to check if an Array is empty.



 Recipe


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

// Check if it is empty

if a.isEmpty {
    print("Ooops, it's empty")
}
else {
    print("No, it's not empty")
}
				

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