summaryrefslogtreecommitdiffhomepage
path: root/go.html.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'go.html.markdown')
-rw-r--r--go.html.markdown10
1 files changed, 10 insertions, 0 deletions
diff --git a/go.html.markdown b/go.html.markdown
index a1be08af..656b1051 100644
--- a/go.html.markdown
+++ b/go.html.markdown
@@ -177,6 +177,14 @@ func learnFlowControl() {
break // Just kidding.
continue // Unreached.
}
+
+ // You can use range to iterate over an array, a slice, a string, a map, or a channel.
+ // range returns one (channel) or two values (array, slice, string and map).
+ for key, value := range map[string]int{"one": 1, "two": 2, "three": 3} {
+ // for each pair in the map, print key and value
+ fmt.Printf("key=%s, value=%d\n", key, value)
+ }
+
// As with for, := in an if statement means to declare and assign
// y first, then test y > x.
if y := expensiveComputation(); y > x {
@@ -378,6 +386,8 @@ There you can follow the tutorial, play interactively, and read lots.
The language definition itself is highly recommended. It's easy to read
and amazingly short (as language definitions go these days.)
+You can play around with the code on [Go playground](https://play.golang.org/p/tnWMjr16Mm). Try to change it and run it from your browser! Note that you can use [https://play.golang.org](https://play.golang.org) as a [REPL](https://en.wikipedia.org/wiki/Read-eval-print_loop) to test things and code in your browser, without even installing Go.
+
On the reading list for students of Go is the [source code to the standard
library](http://golang.org/src/pkg/). Comprehensively documented, it
demonstrates the best of readable and understandable Go, Go style, and Go