count
Returns the number of elements.
Declaration
var count: Int { get }Discussion
To check whether a 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.