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() {
slice1 := make([]int, 0, 10)
// load the slice, cap(slice1) is 10:
for i := 0; i < cap(slice1); i++ {
slice1 = slice1[0:i+1]
slice1[i] = i
fmt.Printf("The length of slice is %d\n", len(slice1))
}
// print the slice:
for i := 0; i < len(slice1); i++ {
fmt.Printf("Slice at %d is %d\n", i, slice1[i])
}
}