maps
This commit is contained in:
parent
d75280c111
commit
0e16b3c8a6
@ -8,7 +8,7 @@ Hello World
|
|||||||
# Switch
|
# Switch
|
||||||
# Arrays
|
# Arrays
|
||||||
# Slices
|
# Slices
|
||||||
# Maps
|
Maps
|
||||||
# Range
|
# Range
|
||||||
# Functions
|
# Functions
|
||||||
# Multiple Return Values
|
# Multiple Return Values
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// Maps are Go's built-in associative data type (sometimes
|
// Maps are Go's built-in [associative data type](http://en.wikipedia.org/wiki/Associative_array)
|
||||||
// called "hashes" or "dicts" in other languages).
|
// (sometimes called _hashes_ or _dicts_ in other languages).
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// To create an empty map, use the builtin `make`:
|
// To create an empty map, use the builtin `make`:
|
||||||
// `make(map[key-type]val-type)`.
|
// `make(map[key-type]val-type)`.
|
||||||
m := make(map[string]int)
|
m := make(map[string]int)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# Note that maps appear in the form `map[k:v k:v]` when
|
||||||
|
# printed with `fmt.Println`.
|
||||||
$ go run maps.go
|
$ go run maps.go
|
||||||
map: map[k1:7 k2:13]
|
map: map[k1:7 k2:13]
|
||||||
v1: 7
|
v1: 7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user