Maps in Go are declared using the syntax __________.

  • var myMap map[keyType]valueType
  • myMap := make(map[keyType]valueType)
  • myMap := map[keyType]valueType{}
  • myMap := map[keyType]valueType
In Go, maps can be declared using the make function or by using a composite literal. The second option (myMap := make(map[keyType]valueType)) is the correct syntax for creating an empty map.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *