Sobes.tech
Junior

What happens to a Map if make or short assignment is not used?

sobes.tech AI

Answer from AI

A map with a zero value (nil) will be created. Such a map cannot hold elements. An attempt to write a value into it will cause a panic at runtime.

// Declaration of a map without initialization
var myMap map[string]int

// myMap == nil

// Attempting to write a value - will cause a panic
// myMap["key"] = 10