Go语言学习之map (The way to go)
生命不止,继续Go go go. 今天与大家分享golang中的map。
map:
One of the most useful data structures in computer science is the hash table. Many hash table implementations exist with varying properties, but in general they offer fast lookups, adds, and deletes. Go provides a built-in map type that implements a hash table.
定义一个map并初始化,根据key获取value
colors := map[string]string{
"bird": "blue",
"snake": "green",
"cat": "black",
}
// Get color of snake.
c := colors[
还没有评论,来说两句吧...