1.

How To Create A Map In Go?

Answer»

You MUST use MAKE function to create a map.

/* declare a variable, by default map will be nil*/
VAR map_variable map[key_data_type]value_data_type
/* define the map as nil map can not be assigned any VALUE*/
map_variable = make(map[key_data_type]value_data_type)

You must use make function to create a map.

/* declare a variable, by default map will be nil*/
var map_variable map[key_data_type]value_data_type
/* define the map as nil map can not be assigned any value*/
map_variable = make(map[key_data_type]value_data_type)



Discussion

No Comment Found