modify 07.1.md

This commit is contained in:
chidouhu
2013-11-20 14:50:00 +08:00
parent 8545fa5ca3
commit 9dbd1c5d2a
10 changed files with 162 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package main
import "fmt"
func main() {
var slice1 []int = make([]int, 10)
// load the array/slice:
for i := 0; i < len(slice1); i++ {
slice1[i] = 5 * i
}
// print the slice:
for i := 0; i < len(slice1); i++ {
fmt.Printf("Slice at %d is %d\n", i, slice1[i])
}
fmt.Printf("\nThe length of slice1 is %d\n", len(slice1))
fmt.Printf("The capacity of slice1 is %d\n", cap(slice1))
}