首页 > 其他 > 详细

A Tour of Go Maps

时间:2014-10-28 00:16:49      阅读:239      评论:0      收藏:0      [点我收藏+]

A map maps keys to values.

Maps must be created with make (not new) before use; the nil map is empty and cannot be assigned to.

package main 

import "fmt"

type Vertex struct{
    Lat, Long float64
}

var m map[string]Vertex

func main() {
    m = make(map[string]Vertex)
    m["Bell Labs"] = Vertex{
        40.68433, -74.39967,
    }
    fmt.Println(m["Bell Labs"])
}

 

A Tour of Go Maps

原文:http://www.cnblogs.com/ghgyj/p/4055443.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!