-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.go
More file actions
36 lines (26 loc) · 735 Bytes
/
Copy pathmap.go
File metadata and controls
36 lines (26 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import "fmt"
func main() {
myMap := make(map[string]int)
myMap["apple"] = 1
myMap["banana"] = 2
myMap["orange"] = 3
appleValue := myMap["apple"]
bananaValue := myMap["banana"]
fmt.Println("Value of apple : ", appleValue)
fmt.Println("Value of Banana : ", bananaValue)
myMap["apple"] = 5
fmt.Println("Updated value of apple : ", myMap["apple"])
delete(myMap, "orange")
fmt.Println("After deleting orange : ", myMap)
value, exists := myMap["banana"]
if exists {
fmt.Println("Value of banana : ", value)
} else {
fmt.Println("Banana not found in the map.")
}
for key, value := range myMap {
fmt.Println("Key : ", key, " Value : ", value)
}
fmt.Println("Length of the map : ", len(myMap))
}