Skip to content

Commit 2baf8ad

Browse files
cuonglmRobert Griesemer
authored and
Robert Griesemer
committed
doc: do not use "==" in slice examples
There's no slice comparison in Go. Change-Id: I5de1766c2adeb56ed12a577a4c46c12b2582b1c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/469015 Reviewed-by: Robert Griesemer <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Cuong Manh Le <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 169203f commit 2baf8ad

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

doc/go_spec.html

+10-10
Original file line numberDiff line numberDiff line change
@@ -6209,7 +6209,7 @@ <h3 id="Assignment_statements">Assignment statements</h3>
62096209
for i, x[i] = range x { // set i, x[2] = 0, x[0]
62106210
break
62116211
}
6212-
// after this loop, i == 0 and x == []int{3, 5, 3}
6212+
// after this loop, i == 0 and x is []int{3, 5, 3}
62136213
</pre>
62146214

62156215
<p>
@@ -7389,16 +7389,16 @@ <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
73897389

73907390
<pre>
73917391
s0 := []int{0, 0}
7392-
s1 := append(s0, 2) // append a single element s1 == []int{0, 0, 2}
7393-
s2 := append(s1, 3, 5, 7) // append multiple elements s2 == []int{0, 0, 2, 3, 5, 7}
7394-
s3 := append(s2, s0...) // append a slice s3 == []int{0, 0, 2, 3, 5, 7, 0, 0}
7395-
s4 := append(s3[3:6], s3[2:]...) // append overlapping slice s4 == []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
7392+
s1 := append(s0, 2) // append a single element s1 is []int{0, 0, 2}
7393+
s2 := append(s1, 3, 5, 7) // append multiple elements s2 is []int{0, 0, 2, 3, 5, 7}
7394+
s3 := append(s2, s0...) // append a slice s3 is []int{0, 0, 2, 3, 5, 7, 0, 0}
7395+
s4 := append(s3[3:6], s3[2:]...) // append overlapping slice s4 is []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
73967396

73977397
var t []interface{}
7398-
t = append(t, 42, 3.1415, "foo") // t == []interface{}{42, 3.1415, "foo"}
7398+
t = append(t, 42, 3.1415, "foo") // t is []interface{}{42, 3.1415, "foo"}
73997399

74007400
var b []byte
7401-
b = append(b, "bar"...) // append string contents b == []byte{'b', 'a', 'r' }
7401+
b = append(b, "bar"...) // append string contents b is []byte{'b', 'a', 'r' }
74027402
</pre>
74037403

74047404
<p>
@@ -7428,9 +7428,9 @@ <h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
74287428
var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
74297429
var s = make([]int, 6)
74307430
var b = make([]byte, 5)
7431-
n1 := copy(s, a[0:]) // n1 == 6, s == []int{0, 1, 2, 3, 4, 5}
7432-
n2 := copy(s, s[2:]) // n2 == 4, s == []int{2, 3, 4, 5, 4, 5}
7433-
n3 := copy(b, "Hello, World!") // n3 == 5, b == []byte("Hello")
7431+
n1 := copy(s, a[0:]) // n1 == 6, s is []int{0, 1, 2, 3, 4, 5}
7432+
n2 := copy(s, s[2:]) // n2 == 4, s is []int{2, 3, 4, 5, 4, 5}
7433+
n3 := copy(b, "Hello, World!") // n3 == 5, b is []byte("Hello")
74347434
</pre>
74357435

74367436

0 commit comments

Comments
 (0)