---
title: count
framework: swift
role: symbol
role_heading: Instance Property
path: swift/anybidirectionalcollection/count
---

# count

The number of elements.

## Declaration

```swift
var count: Int { get }
```

## Discussion

Discussion 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. note: O(n)
