本文共 493 字,大约阅读时间需要 1 分钟。
数组是固定长度的,依稀让我想起了VB;切片是动态的;map一般是键值对
package mainimport ( "fmt")func main() { var username string fmt.Println(username) username = "abc" fmt.Println(username) //array names := [2]string{ "a", "b"} fmt.Println(names) //slice names2 := [...]string{ 1: "Jan", 2: "Feb"} fmt.Println(names2) //map ages := map[string]int{ "jimmy": 31, "tom": 32, } ages["lily"] = 18 fmt.Println(ages) ages["lucy"] += 10 fmt.Println(ages)}
转载地址:http://scpdx.baihongyu.com/