Last active
June 24, 2019 14:23
-
-
Save victorsteven/41a0d976da50f12001a3166aa14dbde0 to your computer and use it in GitHub Desktop.
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() { | |
| //map with a key of string and value of a slice of string: | |
| nameAndHobby := map[string][]string{ | |
| "Steven": []string{"Basket Ball", "Table Tennis", "Coding"}, | |
| "Nnamdi": []string{"Sleeping", "Watching Movie", "Eating"}, | |
| } | |
| //We can add someone else with their hobby: | |
| nameAndHobby["Timi"] = []string{"Watching Cartoon", | |
| "Dreaming", | |
| "Laughing", | |
| "Lazing around", | |
| } | |
| //We can delete from the map: | |
| delete(nameAndHobby, "Steven") | |
| for i, v := range nameAndHobby { | |
| fmt.Printf("%v likes \n", i) | |
| for j, value := range v { | |
| fmt.Printf("\t%v %v\n", j, value) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment