EnumeratedSequence
An enumeration of the elements of a sequence or collection.
Declaration
@frozen struct EnumeratedSequence<Base> where Base : SequenceOverview
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"