Created
May 27, 2014 04:51
-
-
Save shockalotti/967238c091de1ba5af80 to your computer and use it in GitHub Desktop.
Go Golang - multi column map
This file contains hidden or 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" | |
func main() { | |
// a map of other maps | |
elements:= map[string]map[string]string { | |
"H":map[string]string { | |
"name":"Hydrogen", | |
"state":"gas", | |
}, | |
"He":map[string]string { | |
"name":"Helium", | |
"state":"gas", | |
}, | |
"Li":map[string]string { | |
"name":"Lithium", | |
"state":"solid", | |
}, | |
"Be":map[string]string { | |
"name":"Beryllium", | |
"state":"solid", | |
}, | |
"B":map[string]string { | |
"name":"Boron", | |
"state":"solid", | |
}, | |
} | |
if el,ok:=elements["Li"]; ok { | |
fmt.Println(el["name"], el["state"]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment