Created
May 27, 2014 04:42
-
-
Save shockalotti/d5f5f3455c10ca885ede to your computer and use it in GitHub Desktop.
Go Golang - shorter way of writing 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() { | |
elements:= map[string]string { | |
// shorter way of listing key pairs | |
"H":"Hydrogen", | |
"He":"Helium", | |
"Li":"Lithium", | |
"Be":"Beryllium", | |
"B":"Boron", | |
} | |
name, ok:=elements["Li"] | |
fmt.Println(name,ok) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment