diff options
Diffstat (limited to 'doc/go_tutorial.html')
| -rw-r--r-- | doc/go_tutorial.html | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/doc/go_tutorial.html b/doc/go_tutorial.html index d200036b0..4f3f6b94b 100644 --- a/doc/go_tutorial.html +++ b/doc/go_tutorial.html @@ -10,8 +10,7 @@ After you've read this tutorial, you should look at which digs deeper into how the language is used and talks about the style and idioms of programming in Go. Also, slides from a 3-day course about Go are available. -Although they're badly out of date, they provide some -background and a lot of examples: +They provide some background and a lot of examples: <a href='/doc/GoCourseDay1.pdf'>Day 1</a>, <a href='/doc/GoCourseDay2.pdf'>Day 2</a>, <a href='/doc/GoCourseDay3.pdf'>Day 3</a>. @@ -935,12 +934,12 @@ We can apply <code>Sort</code> to any type that implements <code>Len</code>, <co The <code>sort</code> package includes the necessary methods to allow sorting of arrays of integers, strings, etc.; here's the code for arrays of <code>int</code> <p> -<pre> <!-- progs/sort.go /type.*IntArray/ /Swap/ --> -33 type IntArray []int +<pre> <!-- progs/sort.go /type.*IntSlice/ /Swap/ --> +33 type IntSlice []int -35 func (p IntArray) Len() int { return len(p) } -36 func (p IntArray) Less(i, j int) bool { return p[i] < p[j] } -37 func (p IntArray) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +35 func (p IntSlice) Len() int { return len(p) } +36 func (p IntSlice) Less(i, j int) bool { return p[i] < p[j] } +37 func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } </pre> <p> Here we see methods defined for non-<code>struct</code> types. You can define methods @@ -953,7 +952,7 @@ to test that the result is sorted. <pre> <!-- progs/sortmain.go /func.ints/ /^}/ --> 12 func ints() { 13 data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586} -14 a := sort.IntArray(data) +14 a := sort.IntSlice(data) 15 sort.Sort(a) 16 if !sort.IsSorted(a) { 17 panic("fail") |
