Skip to content

Commit ff6a8fd

Browse files
committed
mention arrays of arrays and slices of slices
Fixes #113. R=gri, rsc CC=golang-dev https://golang.org/cl/159049
1 parent 28e392d commit ff6a8fd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/go_spec.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,16 @@ <h3 id="Array_types">Array types</h3>
607607
using the built-in function <code>len(a)</code>, which is a
608608
compile-time constant. The elements can be indexed by integer
609609
indices 0 through the <code>len(a)-1</code><a href="#Indexes">Indexes</a>).
610+
Array types are always one-dimensional but may be composed to form
611+
multi-dimensional types.
610612
</p>
611613

612614
<pre>
613615
[32]byte
614616
[2*N] struct { x, y int32 }
615617
[1000]*float64
618+
[3][5]int
619+
[2][2][2]float64 // same as [2]([2]([2]float64))
616620
</pre>
617621

618622
<h3 id="Slice_types">Slice types</h3>
@@ -690,6 +694,13 @@ <h3 id="Slice_types">Slice types</h3>
690694
new([100]int)[0:50]
691695
</pre>
692696

697+
<p>
698+
Like arrays, slices are always one-dimensional but may be composed to construct
699+
higher-dimensional objects.
700+
With arrays of arrays, the inner arrays are, by construction, always the same length;
701+
however with slices of slices (or arrays of slices), the lengths may vary dynamically.
702+
Moreover, the inner slices must be allocated individually (with <code>make</code>).
703+
</p>
693704

694705
<h3 id="Struct_types">Struct types</h3>
695706

0 commit comments

Comments
 (0)