Go for: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 13: Line 13:


=<tt>for</tt> Controlled by a Condition=
=<tt>for</tt> Controlled by a Condition=
<pre>
for a < b {
    a *= 2
}
</pre>


=<tt>for</tt> Controlled by a "for" Clause=
=<tt>for</tt> Controlled by a "for" Clause=


=<tt>for</tt> Controlled by a "range" Clause=
=<tt>for</tt> Controlled by a "range" Clause=

Revision as of 05:18, 23 March 2016

External

Internal

Overview

A for statement specifies repeated execution of a block. For more details on blocks, see Go blocks.

The iteration is controlled by a condition, a "for" clause, or a "range" clause.

for Controlled by a Condition

for a < b {
    a *= 2
}

for Controlled by a "for" Clause

for Controlled by a "range" Clause