![]() |
VOOZH | about |
The Swift language supports different collections like a set, array, dictionary, etc. An array is an ordered generic collection that is used to keep the same type of data like int, float, string, etc., here you are not allowed to store the value of another type. It also keeps duplicate values of the same type. It can be mutable and immutable. When we assign an array to a variable, then that array is known as mutable whereas when we assign an array to a constant, then that array is known as immutable. In the Swift array, we check if the given array is empty or not using the isEmpty property. This property is used to find whether the given array is empty or not. If the given array is empty then this property will return true otherwise it will return false.
Syntax:
arrayName.isEmpty
Here,
arrayName is the object of the array class.
Return Value: This property will return true if the given array is empty or return false if the given array contains elements.
Example 1:
Output:
Is the GEmpSalary is empty or not? false Is the GEmployee is empty or not? true
Example 2:
Output:
No! the given array is not empty