Junior — Middle
How can you create a map (dictionary) in a chosen programming language?
sobes.tech AI
Answer from AI
In Go, a map is created using the built-in make function. The syntax is as follows:
m := make(map[KeyType]ValueType)
For example, to create a map from strings to integers:
m := make(map[string]int)
m["apple"] = 5
m["banana"] = 3
You can also create a map with a literal initialization:
m := map[string]int{"apple": 5, "banana": 3}
A map in Go is a hash table that allows for fast retrieval, addition, and deletion of elements by key.