From bc23ce679061b8f41f551578181b9feeb24f5c0a Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Fri, 9 Jan 2009 15:16:31 -0800 Subject: update tutorial to new language. add a section on printing add a section on allocation R=rsc DELTA=500 (278 added, 15 deleted, 207 changed) OCL=22381 CL=22456 --- doc/progs/sum.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/progs/sum.go') diff --git a/doc/progs/sum.go b/doc/progs/sum.go index c8e7b10a7..3ca1a5877 100644 --- a/doc/progs/sum.go +++ b/doc/progs/sum.go @@ -4,7 +4,7 @@ package main -func sum(a *[]int) int { // returns an int +func sum(a []int) int { // returns an int s := 0; for i := 0; i < len(a); i++ { s += a[i] @@ -14,6 +14,6 @@ func sum(a *[]int) int { // returns an int func main() { - s := sum(&[]int{1,2,3}); // pass address of int array + s := sum([3]int{1,2,3}); // a slice of the array is passed to sum print(s, "\n"); } -- cgit v1.2.3