Commit cec0954d authored by Rob Pike's avatar Rob Pike

spec: add example for continue to label

Make the break example slightly more interesting
Update #5725
Effective Go will be updated in a separate CL.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13368054
parent 6a1022a0
<!--{ <!--{
"Title": "The Go Programming Language Specification", "Title": "The Go Programming Language Specification",
"Subtitle": "Version of Sep 12, 2013", "Subtitle": "Version of Sep 16, 2013",
"Path": "/doc/spec" "Path": "/doc/spec"
}--> }-->
...@@ -3345,7 +3345,7 @@ As an exception to the addressability requirement, <code>x</code> may also be a ...@@ -3345,7 +3345,7 @@ As an exception to the addressability requirement, <code>x</code> may also be a
(possibly parenthesized) (possibly parenthesized)
<a href="#Composite_literals">composite literal</a>. <a href="#Composite_literals">composite literal</a>.
If the evaluation of <code>x</code> would cause a <a href="#Run_time_panics">run-time panic</a>, If the evaluation of <code>x</code> would cause a <a href="#Run_time_panics">run-time panic</a>,
then the evaluation of <code>&x</code> does too. then the evaluation of <code>&amp;x</code> does too.
</p> </p>
<p> <p>
...@@ -3365,7 +3365,7 @@ will cause a <a href="#Run_time_panics">run-time panic</a>. ...@@ -3365,7 +3365,7 @@ will cause a <a href="#Run_time_panics">run-time panic</a>.
var x *int = nil var x *int = nil
*x // causes a run-time panic *x // causes a run-time panic
&*x // causes a run-time panic &amp;*x // causes a run-time panic
</pre> </pre>
...@@ -4997,11 +4997,17 @@ and that is the one whose execution terminates. ...@@ -4997,11 +4997,17 @@ and that is the one whose execution terminates.
</p> </p>
<pre> <pre>
L: OuterLoop:
for i &lt; n { for i = 0; i &lt; n; i++ {
switch i { for j = 0; j &lt; m; j++ {
case 5: switch a[i][j] {
break L case nil:
state = Error
break OuterLoop
case item:
state = Found
break OuterLoop
}
} }
} }
</pre> </pre>
...@@ -5023,6 +5029,18 @@ If there is a label, it must be that of an enclosing ...@@ -5023,6 +5029,18 @@ If there is a label, it must be that of an enclosing
advances. advances.
</p> </p>
<pre>
RowLoop:
for y, row := range rows {
for x, data := range row {
if data == endOfRow {
continue RowLoop
}
row[x] = data + bias(x, y)
}
}
</pre>
<h3 id="Goto_statements">Goto statements</h3> <h3 id="Goto_statements">Goto statements</h3>
<p> <p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment