From e23cb95e591335063c5c751db4300541c61bf738 Mon Sep 17 00:00:00 2001
From: Manuel Hutter
Date: Fri, 22 Jan 2016 15:05:12 +0100
Subject: [PATCH] Extended `for`: Added explanation of `continue`.
---
examples/for/for.go | 8 ++++++++
examples/for/for.hash | 4 ++--
examples/for/for.sh | 5 +++++
public/for | 27 +++++++++++++++++++++++++--
4 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/examples/for/for.go b/examples/for/for.go
index 7bdbabf..c9a12e6 100644
--- a/examples/for/for.go
+++ b/examples/for/for.go
@@ -26,4 +26,12 @@ func main() {
fmt.Println("loop")
break
}
+
+ // You can also `continue` to the next loop
+ for n := 0; n <= 9; n++ {
+ if n%2 == 0 {
+ continue
+ }
+ fmt.Println(n)
+ }
}
diff --git a/examples/for/for.hash b/examples/for/for.hash
index 954a23c..bc4f565 100644
--- a/examples/for/for.hash
+++ b/examples/for/for.hash
@@ -1,2 +1,2 @@
-e7dbd5f44ea79a3eb41e4535575197b9eadc0e03
-mGqqcBZ0jv
+0567bfd0e134cfd06f893c445dae72dd8d6064f6
+egSvQrHmW6
diff --git a/examples/for/for.sh b/examples/for/for.sh
index 1e564fc..8395b92 100644
--- a/examples/for/for.sh
+++ b/examples/for/for.sh
@@ -6,6 +6,11 @@ $ go run for.go
8
9
loop
+1
+3
+5
+7
+9
# We'll see some other `for` forms later when we look at
# `range` statements, channels, and other data
diff --git a/public/for b/public/for
index 960bc9e..3e885f8 100644
--- a/public/for
+++ b/public/for
@@ -40,7 +40,7 @@ three basic types of for
loops.
-
+
@@ -110,12 +110,30 @@ until you break out of the loop or return from
the enclosing function.
|
-
+ |
for {
fmt.Println("loop")
break
}
+
+
+ |
+
+
+
+
+ You can also continue to the next loop
+
+ |
+
+
+ for n := 0; n <= 9; n++ {
+ if n%2 == 0 {
+ continue
+ }
+ fmt.Println(n)
+ }
}
@@ -140,6 +158,11 @@ the enclosing function.
8
9
loop
+1
+3
+5
+7
+9
|