map[K]V
, where K
and V
are the types of its keys and values.map
using var declaration. We are defining string
to be keys for the map and string
to be values. Since map is declared but not initialized with any value, it will be a nil
map. make
function call. make
will perform the required memory allocation required to use map. We can add elements to map using map[key] = value
semantics. make
function call is not required when using map literal.==
comparison.nil
and empty maps have len()
as zero.for...range
loop for iteration. range
works as follows for a mapfor key,value :=range map { // }
ok
which tells if key was found or not. XYZ
and ABC
, both returns empty string. For XYZ
, value is empty string, while for ABC
, it is missing from map.value,ok
semantics.map[key]= value
semantic to update value for given key.delete(mapName,key)