---
title: count()
framework: combine
role: symbol
role_heading: Instance Method
path: combine/publisher/count()
---

# count()

Publishes the number of elements received from the upstream publisher.

## Declaration

```swift
func count() -> Publishers.Count<Self>
```

## Return Value

Return Value A publisher that consumes all elements until the upstream publisher finishes, then emits a single value with the total number of elements received.

## Discussion

Discussion Use count() to determine the number of elements received from the upstream publisher before it completes: let numbers = (0...10) cancellable = numbers.publisher     .count()     .sink { print("\($0)") }

// Prints: "11"

## See Also

### Applying mathematical operations on elements

- [max()](combine/publisher/max().md)
- [max(by:)](combine/publisher/max(by:).md)
- [tryMax(by:)](combine/publisher/trymax(by:).md)
- [min()](combine/publisher/min().md)
- [min(by:)](combine/publisher/min(by:).md)
- [tryMin(by:)](combine/publisher/trymin(by:).md)
