Re: [go-nuts] Re: Copying slice over itself

2017-09-07 Thread peterGo
Rob, "Two slices sharing an array will, however, share their last element. Here is a better test, but this is pretty magical stuff: https://play.golang.org/p/SZgpCh9D-l"; a := []int{0, 1, 2, 3, 4, 5, 6, 7} s := a[1:3:5] https://play.golang.org/p/Q

Re: [go-nuts] Re: Copying slice over itself

2017-09-07 Thread Rob Pike
That test is only sufficient if the zeroth elements in the two slices are at the same address, which is often not true: https://play.golang.org/p/TH53Pxt5Do Two slices sharing an array will, however, share their last element. Here is a better test, but this is pretty magical stuff: https://play.go