EnumeratedSequence

    An enumeration of the elements of a sequence or collection.

    @frozen struct EnumeratedSequence<Base> where Base : Sequence

    EnumeratedSequence is a sequence of pairs (n, x), where ns are consecutive Int values starting at zero, and xs are the elements of a base sequence.

    To create an instance of EnumeratedSequence, call enumerated() on a sequence or collection. The following example enumerates the elements of an array.

    var s = ["foo", "bar"].enumerated()
    for (n, x) in s {
        print("\(n): \(x)")
    }
    // Prints "0: foo"
    // Prints "1: bar"

    Citizens in Swift

    where Base:Sequence

    Conformances

    Types

    Instance members

    Instance features

    Show obsolete interfaces (1)

    Hide obsolete interfaces

    Citizens in Swift

    where Base:Sequence, Base:Sendable

    Conformances