Last active
August 29, 2015 14:05
-
-
Save kamatama41/b1ec3e6aaaa9ee878cb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Key struct { | |
Name string | |
} | |
type Vertex struct { | |
Lat, Long float64 | |
} | |
var m map[Key]Vertex | |
func main() { | |
m = make(map[Key]Vertex) | |
m[Key{"Bell Labs"}] = Vertex{ | |
40.68433, -74.39967, | |
} | |
val := m[Key{"Bell Labs"}] | |
fmt.Println(val) | |
// 取り出した変数を変更してもMapの中身に影響は無い | |
val.Lat = 1.234 | |
val2 := m[Key{"Bell Labs"}] | |
fmt.Println(val2) | |
} | |
// result | |
//{40.68433 -74.39967} | |
//{40.68433 -74.39967} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment