We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5c72362 + b9eb743 commit 4a3fb02Copy full SHA for 4a3fb02
advanced/map.go
@@ -0,0 +1,30 @@
1
+package main
2
+
3
+import (
4
+ "fmt"
5
+)
6
7
+func main() {
8
+ myMap := make(map[string]string)
9
10
+ //Insertionn in a map
11
+ myMap["A"] = "apple"
12
+ myMap["B"] = "ball"
13
+ myMap["C"] = "cat"
14
15
+ //Traverse a map
16
+ fmt.Println("Printing Map..........",)
17
+ for key, value := range myMap {
18
+ fmt.Println("Key: ", key, " Value: ", value)
19
+ }
20
21
+ //Delete a key-value pair from a map
22
+ //Deleting Key: "C" from map
23
+ fmt.Println("Deleting a key from Map..........",)
24
+ delete(myMap, "C")
25
26
+ //Find the value associated with a key
27
+ fmt.Println("Finding a key from Map..........",)
28
+ fmt.Println("Value for key 'A': ", myMap["A"])
29
+}
30
0 commit comments