Instance Propertyswift 6.0.3Swift

count

The number of elements in the collection.

var count: Int { get }

To check whether the collection is empty, use its isEmpty property instead of comparing count to zero. Unless the collection guarantees random-access performance, calculating count can be an O(n) operation.