Commit 0f7acf11 authored by Robert Griesemer's avatar Robert Griesemer

go spec: attempt at clarifying language for "append"

Specifically, fix a wrong comment.

Fixes #1717.

R=r, rsc
CC=golang-dev
https://golang.org/cl/4445050
parent 3cb973ff
<!-- title The Go Programming Language Specification -->
<!-- subtitle Version of Apr 5, 2011 -->
<!-- subtitle Version of Apr 19, 2011 -->
<!--
TODO
......@@ -4541,13 +4541,14 @@ Two built-in functions assist in common slice operations.
<p>
The function <code>append</code> appends zero or more values <code>x</code>
to a slice <code>s</code> and returns the resulting slice, with the same type
as s. Each value must be <a href="#Assignability">assignable</a> to the slice's
element type.
to <code>s</code> of type <code>S</code>, which must be a slice type, and
returns the resulting slice, also of type <code>S</code>.
Each value <code>x</code> must be <a href="#Assignability">assignable</a> to
the <a href="#Slice_types">element type</a> of <code>S</code>.
</p>
<pre class="grammar">
append(s S, x ...T) S // S is assignable to []T
append(s S, x ...T) S // T is the element type of S
</pre>
<p>
......@@ -4562,6 +4563,9 @@ s0 := []int{0, 0}
s1 := append(s0, 2) // append a single element s1 == []int{0, 0, 2}
s2 := append(s1, 3, 5, 7) // append multiple elements s2 == []int{0, 0, 2, 3, 5, 7}
s3 := append(s2, s0...) // append a slice s3 == []int{0, 0, 2, 3, 5, 7, 0, 0}
var t []interface{}
t = append(t, 42, 3.1415, "foo") t == []interface{}{42, 3.1415, "foo"}
</pre>
<p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment