-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmaps.go
More file actions
33 lines (25 loc) · 690 Bytes
/
maps.go
File metadata and controls
33 lines (25 loc) · 690 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
package main
import (
"fmt"
)
func main() {
currency := map[string]string{
"AUD": "Australia Dollar",
"GBP": "Great Britain Pound",
"JPY": "Japan Yen",
"CHF": "Switzerland Franc",
}
//a. Adding to the map:
currency["USD"] = "USA Dollar"
fmt.Println("Currency with USD added: ", currency)
//b. Remove from the map:
delete(currency, "GBP")
fmt.Println("Currency with GBP deleted: ", currency)
//c. Replacing one entry with another:
currency["AUD"] = "New Zealand Dollar"
fmt.Println("Currency with AUD value replaced with NZD: ", currency)
//Ranging through the map:
for key, value := range currency {
fmt.Printf("%v might be equal to: %v\n", key, value)
}
}