Go Maps: Difference between revisions
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
[[Go_Variables#Variable_Initialization_with_Type_Inference_in_Long_Declaration|Long variable declaration and initialization with type inference]]: | [[Go_Variables#Variable_Initialization_with_Type_Inference_in_Long_Declaration|Long variable declaration and initialization with type inference]]: | ||
<syntaxhighlight lang='go'> | <syntaxhighlight lang='go'> | ||
var mm = map[string]int {"A:1, "B":2} | var mm = map[string]int {"A":1, "B":2} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Go_Variables#Short_Variable_Declaration|Short variable declaration]]: | [[Go_Variables#Short_Variable_Declaration|Short variable declaration]]: | ||
<syntaxhighlight lang='go'> | <syntaxhighlight lang='go'> | ||
mm := map[string]int {"A:1, "B":2} | mm := map[string]int {"A":1, "B":2} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 23:34, 26 August 2024
External
Internal
Overview
Maps and Pass-by-Value
Pointers to Maps
nil and Empty Map
nil Map
Empty Map
Declaration and Initialization
Initialization with make()
Initialization with a Composite Literal
Composite literals can be used for map initialization.
Long variable declaration and initialization with type inference:
var mm = map[string]int {"A":1, "B":2}
mm := map[string]int {"A":1, "B":2}