Iterator

The iterator for EnumeratedSequence.

@frozen struct Iterator

An instance of this iterator wraps a base iterator and yields successive Int values, starting at zero, along with the elements of the underlying base iterator. The following example enumerates the elements of an array:

var iterator = ["foo", "bar"].enumerated().makeIterator()
iterator.next() // (0, "foo")
iterator.next() // (1, "bar")
iterator.next() // nil

To create an instance, call enumerated().makeIterator() on a sequence or collection.