ated()</code> on a
sequence or collection. The following example enumerates the elements of
an array.</p>

<pre><code class="language-swift">var s = [&quot;foo&quot;, &quot;bar&quot;].enumerated()
for (n, x) in s {
    print(&quot;\(n): \(x)&quot;)
}
// Prints &quot;0: foo&quot;
// Prints &quot;1: bar&quot;</code></pre>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">Sequence</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;<