Is the array empty?

To check whether an array is empty (does not contain any elements), we use the isEmpty property. This property will return true if the array is empty and false if it is not. The following example shows how to check whether an array is empty or not:

var arrayOne = [1,2]  
var arrayTwo = [Int]() 
arrayOne.isEmpty  //Returns false because the array is not empty  
arrayTwo.isEmpty  //Returns true because the array is empty 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset