Go语言学习之map (The way to go)

向右看齐 2022-06-18 07:59 369阅读 0赞

生命不止,继续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

  1. colors := map[string]string{
  2. "bird": "blue",
  3. "snake": "green",
  4. "cat": "black",
  5. }
  6. // Get color of snake.
  7. c := colors[

发表评论

表情:
评论列表 (有 0 条评论,369人围观)

还没有评论,来说两句吧...

相关阅读