summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-11-20 15:47:15 -0800
committerRob Pike <r@golang.org>2009-11-20 15:47:15 -0800
commitda3ae8661a33a1b8367b4d954aa04dfa8aa220ac (patch)
tree7e036209a976a363e4f732a5ae949eae477538d7
parent17dc6451cd896dac0a91367e976e1a94af9a5e20 (diff)
downloadgolang-da3ae8661a33a1b8367b4d954aa04dfa8aa220ac.tar.gz
mention arrays of arrays and slices of slices
Fixes issue 113. R=gri, rsc CC=golang-dev http://codereview.appspot.com/159049
-rw-r--r--doc/go_spec.html11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html
index 5eaeea04b..8a247461d 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -607,12 +607,16 @@ integer value. The length of array <code>a</code> can be discovered
using the built-in function <code>len(a)</code>, which is a
compile-time constant. The elements can be indexed by integer
indices 0 through the <code>len(a)-1</code> (ยง<a href="#Indexes">Indexes</a>).
+Array types are always one-dimensional but may be composed to form
+multi-dimensional types.
</p>
<pre>
[32]byte
[2*N] struct { x, y int32 }
[1000]*float64
+[3][5]int
+[2][2][2]float64 // same as [2]([2]([2]float64))
</pre>
<h3 id="Slice_types">Slice types</h3>
@@ -690,6 +694,13 @@ make([]int, 50, 100)
new([100]int)[0:50]
</pre>
+<p>
+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 <code>make</code>).
+</p>
<h3 id="Struct_types">Struct types</h3>