Conteúdo do Curso
Introduction to GoLang
Introduction to GoLang
Accessing Map Values
We can access the value corresponding to a key in a map using the following syntax:
index.go
For example:
index.go
The expression prices["apple"]
essentially references the memory location where the value 100
is stored; hence, it acts like a variable. Therefore, we can edit the value stored at that key using the =
operator:
index.go
We can use the same assignment syntax to create a new key in the map:
If the provided keyName
doesn't exist in the map, it will create and add a new key to the map with the assigned value.
index.go
Tudo estava claro?
Conteúdo do Curso
Introduction to GoLang
Introduction to GoLang
Accessing Map Values
We can access the value corresponding to a key in a map using the following syntax:
index.go
For example:
index.go
The expression prices["apple"]
essentially references the memory location where the value 100
is stored; hence, it acts like a variable. Therefore, we can edit the value stored at that key using the =
operator:
index.go
We can use the same assignment syntax to create a new key in the map:
If the provided keyName
doesn't exist in the map, it will create and add a new key to the map with the assigned value.
index.go
Tudo estava claro?