Instance Propertyswift 6.0.3Swift

count

The number of elements.

var count: Int { get }

To check whether a collection is empty, use its isEmpty property instead of comparing count to zero. Calculating count can be an O(n) operation.