Shadow
golang的数组和切片的区别
golang的数组和切片的区别
package main
import (
"fmt"
)
func main() {
//数组类型,类型带数字
var arr = [...]int{0, 1, 5, 15, 5, 1}
//切片类型,类型没有数字
var arr3 = []int{233, 324, 234, 4354354, 543, 54, 5, 435, 43}
fmt.Printf("%T\n",arr) // [6]int
fmt.Printf("%T",arr3) // []int
}
Dcr163的博客
http://dcr163.cn/573.html(转载时请注明本文出处及文章链接)