File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1212
1313<a href =" https://github.com/java-aodeng/golang-examples/blob/master/go-06/1.md " >第06章 数组和切片</a > :<a href =" https://t.zsxq.com/3N3jMB2 " >星球链接</a >
1414
15+ <a href =" https://github.com/java-aodeng/golang-examples/blob/master/go-07/1.md " >第07章 Map 声明、元素访问及遍历</a > :<a href =" https://t.zsxq.com/qvvzZb2 " >星球链接</a >
16+
1517## golang星球学习基地
1618> 学习更多,快来星球吧,这个星球存在的意义只有一个:就是学习……
1719
1820![ ] ( https://i.loli.net/2019/06/13/5d01b9fbec81470229.png )
1921
20- 第07章 Map 声明、元素访问及遍历 :<a href =" https://t.zsxq.com/qvvzZb2 " >星球链接</a >
21-
2222第08章 Map与工厂模式,在Go语言中实现Set :<a href =" https://t.zsxq.com/qvvzZb2 " >星球链接</a >
2323
2424第09章 字符串 :<a href =" https://t.zsxq.com/qvvzZb2 " >星球链接</a >
Original file line number Diff line number Diff line change 99
1010意义:分享知识,提升自己
1111
12- ## 1.1
12+ ## 1.1 Map声明
13+ map key不存在,value默认会为0(重点注意)
1314
15+ m:=map[ string] int{"a":1,"aa":2,"aaa":3}
16+
17+ m1:=map[ string] int{}
18+ m1[ "a"] =1
19+
20+ ```
21+ func TestMap(t *testing.T) {
22+ m:=map[string]int{"a":1,"aa":2,"aaa":3}
23+ t.Log(m["a"])
24+ }
25+ ```
1426## golang星球学习基地
1527> 学习更多,快来星球吧,这个星球存在的意义只有一个:就是学习……
1628
Original file line number Diff line number Diff line change 1+ package go_07
2+
3+ import "testing"
4+
5+ func TestMap (t * testing.T ) {
6+ m := map [string ]int {"a" :1 ,"aa" :2 ,"aaa" :3 }
7+ t .Log (m ["a" ])
8+ }
9+
10+ func TestTraveMap ( t * testing.T ) {
11+ m := map [int ]int {1 :1 ,2 :4 ,3 :9 }
12+
13+ for k ,v := range m {
14+ t .Log (k ,v )
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments