Sobes.tech
Senior

On line 15, the map declaration should be with square brackets, not curly braces. Why?

sobes.tech AI

Answer from AI

In Go, declaring a map requires the use of square brackets to specify the key type because of the language syntax. Square brackets denote indexing or key access, and in map declarations, they indicate the key type, followed by the value type.

Curly braces in Go are used for initializing values, such as struct literals or slices.

Example of a correct map declaration:

var m map[string]int

Here, string is the key type, and int is the value type. Writing with curly braces would be a syntax error, as curly braces are not intended for specifying types in declarations.

On line 15, the map declaration should be with square… - sobes.tech