Hello
I have tried (and modified) from Golang Tour :
package main
import "fmt"
func main() {
var s []int
printSlice(s)
s = append(s, 1)
printSlice(s)
s = append(s, 2)
printSlice(s)
s = append(s, 3)
printSlice(s)
s = append(s, 4)
printSlice(s)
s = append(s, 5)
printSlice(s)
}
func printSlice(s []int) {
fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}
But i get the following :
len=0 cap=0 []
len=1 cap=2 [1]
len=2 cap=2 [1 2]
len=3 cap=4 [1 2 3]
len=4 cap=4 [1 2 3 4]
len=5 cap=8 [1 2 3 4 5]
The question is capacity.
Why not : 0,1,2,3,4,5 as length ?
Thnak you Attila
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.