h-loops">view current version</a>.
</div>
<div id="foreach-loops" class="section level2">
<h2><span class="header-section-number">7.6</span> Foreach Loops</h2>
<p>A second form of for loops allows iteration over elements of
containers. If <code>ys</code> is an expression denoting a container (vector,
row vector, matrix, or array) with elements of type <code>T</code>, then the
following is a well-formed foreach statement.</p>
<pre><code>for (y in ys) {
  ... do something with y ...
}</code></pre>
<p>The orde