The count
property of an array in Swift gets the number of elements in the array.
arr.count
This does not take any parameters.
It returns an integer value which is the number of elements contained in the array arr
.
// create arraysvar gnaam = ["Google", "Netflix", "Amazon", "Apple", "Facebook", "Meta"];var letters = ["a", "b", "c", "d", "e"];var numbers = [1, 2, 3];// print number of elementsprint(gnaam.count);print(letters.count);print(numbers.count);
gnaam
, letters
, and numbers
.count
property of the arrays.