content: clean up slice of slices code example
The variable represents a board, not a game.
Also, there's no point in creating a helper function to print
the board, since it's only printed once.
Change-Id: I34897302d80d0aa8de63a424f570c39f64fa6538
Reviewed-on: https://go-review.googlesource.com/19400
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/content/moretypes/slices-of-slice.go b/content/moretypes/slices-of-slice.go
index 2604a17..66f1019 100644
--- a/content/moretypes/slices-of-slice.go
+++ b/content/moretypes/slices-of-slice.go
@@ -9,24 +9,20 @@
func main() {
// Create a tic-tac-toe board.
- game := [][]string{
+ board := [][]string{
[]string{"_", "_", "_"},
[]string{"_", "_", "_"},
[]string{"_", "_", "_"},
}
// The players take turns.
- game[0][0] = "X"
- game[2][2] = "O"
- game[2][0] = "X"
- game[1][0] = "O"
- game[0][2] = "X"
+ board[0][0] = "X"
+ board[2][2] = "O"
+ board[2][0] = "X"
+ board[1][0] = "O"
+ board[0][2] = "X"
- printBoard(game)
-}
-
-func printBoard(s [][]string) {
- for i := 0; i < len(s); i++ {
- fmt.Printf("%s\n", strings.Join(s[i], " "))
+ for i := 0; i < len(board); i++ {
+ fmt.Printf("%s\n", strings.Join(board[i], " "))
}
}