content: clarify slices code example Giving the slice a slightly more descriptive name makes the formatted string in the loop a bit less cryptic. Change-Id: Idd17014d7528f133c747df080c59a440c533eb0f Reviewed-on: https://go-review.googlesource.com/19402 Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/content/moretypes.article b/content/moretypes.article index 8a203aa..904a578 100644 --- a/content/moretypes.article +++ b/content/moretypes.article
@@ -83,7 +83,7 @@ `[]T` is a slice with elements of type `T`. -`len(s)` returns the length of slice `s`. +`len(primes)` returns the length of slice `primes`. .play moretypes/slices.go
diff --git a/content/moretypes/slices.go b/content/moretypes/slices.go index 62b89d7..385283c 100644 --- a/content/moretypes/slices.go +++ b/content/moretypes/slices.go
@@ -5,10 +5,10 @@ import "fmt" func main() { - s := []int{2, 3, 5, 7, 11, 13} - fmt.Println("s ==", s) + primes := []int{2, 3, 5, 7, 11, 13} + fmt.Println("primes ==", primes) - for i := 0; i < len(s); i++ { - fmt.Printf("s[%d] == %d\n", i, s[i]) + for i := 0; i < len(primes); i++ { + fmt.Printf("primes[%d] == %d\n", i, primes[i]) } }