Last active
August 29, 2015 14:11
-
-
Save mmcdaris/9533bb6dc6aa95bc9d22 to your computer and use it in GitHub Desktop.
Map Literals Continued
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 Cat struct { | |
size, snack string | |
} | |
var cats = map[string]Cat{ | |
"bello": {"med-small", "Bonito Flakes"}, | |
"lola": {"large", "Nuggets"}, | |
} | |
func main() { | |
catStats(cats) | |
} | |
func catStats(cats map[string]Cat) { | |
for name, cat := range cats { | |
fmt.Printf("%s is %s in size, favorite snack is %s.\n", | |
name, cat.size, cat.snack) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment