<aside> 💡 Happy gopher~

</aside>

string

fields&maps

func WordCount(s string) map[string]int {
	cntMap := make(map[string]int)
	strs := strings.Fields(s)
	for _, s := range strs {
		i := cntMap[s]
		cntMap[s] = i + 1
	}

	return cntMap
}
strs := strings.Fields(s)

for _, s := range strs {
 // xxx
}
// 如下是非法的. 
y := x++
// 
x++
y = x


map

<aside> 💡 如何遍历map

</aside>