mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
Mention that the append trick for copying fails on the empty slice
parent
c7b68225bd
commit
70da14d4e9
@ -11,7 +11,7 @@ a = append(a, b...)
|
|||||||
```go
|
```go
|
||||||
b = make([]T, len(a))
|
b = make([]T, len(a))
|
||||||
copy(b, a)
|
copy(b, a)
|
||||||
// or
|
// or, if a is not the empty slice,
|
||||||
b = append([]T(nil), a...)
|
b = append([]T(nil), a...)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user