show inline map initialization

This commit is contained in:
Mark McGranaghan 2012-10-10 21:00:30 -07:00
parent c852c887d7
commit 4549dbcaca
3 changed files with 7 additions and 1 deletions

View File

@ -29,7 +29,7 @@ func main() {
fmt.Println("dcl:", y)
// The builtin `len` returns the length of an array.
fmt.Println("len:", len(x))
fmt.Println("len:", len(y))
// Array types are one-dimensional, but you can
// compose types to build multi-dimensional data

View File

@ -41,4 +41,9 @@ func main() {
// like `0` or `""`.
_, prs := m["k2"]
fmt.Println("prs:", prs)
// You can also declare and initialize a new map in
// the same line with this syntax.
n := map[string]int{"foo": 1, "bar": 2}
fmt.Println("map:", n)
}

View File

@ -6,3 +6,4 @@ v1: 7
len: 2
map: map[k1:7]
prs: false
map: map[foo:1 bar:2]