Instance Property


The number of elements in the collection.


var count: Int { get }


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.

Complexity: O(1) if the collection conforms to RandomAccessCollection; otherwise, O(n), where n is the length of the collection.

See Also

Inspecting a Range

var isEmpty: Bool

A Boolean value indicating whether the range contains no elements.

let lowerBound: Bound

The range’s lower bound.

let upperBound: Bound

The range’s upper bound.