From: Rob Pike Date: Fri, 20 Nov 2009 23:47:15 +0000 (-0800) Subject: mention arrays of arrays and slices of slices X-Git-Tag: weekly.2009-12-07~162 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ff6a8fd77916b25db6681f4ff53413ee0c03c5a3;p=gostls13.git mention arrays of arrays and slices of slices Fixes #113. R=gri, rsc CC=golang-dev https://golang.org/cl/159049 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 5eaeea04bc..8a247461da 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -607,12 +607,16 @@ integer value. The length of array a can be discovered using the built-in function len(a), which is a compile-time constant. The elements can be indexed by integer indices 0 through the len(a)-1 (§Indexes). +Array types are always one-dimensional but may be composed to form +multi-dimensional types.

 [32]byte
 [2*N] struct { x, y int32 }
 [1000]*float64
+[3][5]int
+[2][2][2]float64  // same as [2]([2]([2]float64))
 

Slice types

@@ -690,6 +694,13 @@ make([]int, 50, 100) new([100]int)[0:50] +

+Like arrays, slices are always one-dimensional but may be composed to construct +higher-dimensional objects. +With arrays of arrays, the inner arrays are, by construction, always the same length; +however with slices of slices (or arrays of slices), the lengths may vary dynamically. +Moreover, the inner slices must be allocated individually (with make). +

Struct types