<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/EnumeratedSequence",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s18EnumeratedSequenceV"
  },
  "title" : "EnumeratedSequence"
}
-->

# EnumeratedSequence

An enumeration of the elements of a sequence or collection.

```
@frozen struct EnumeratedSequence<Base> where Base : Sequence
```

## Overview

`EnumeratedSequence` is a sequence of pairs (*n*, *x*), where *n*s are
consecutive `Int` values starting at zero, and *x*s 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"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)