|
|
|
|
|
by simiones
1749 days ago
|
|
Too late to edit, but I made a significant mistake in the Go code: v[3] would always be a runtime error unless we explicitly modify *ref inside the function (ref = append(ref, 4), in which case v[3] == 4 would always be true). This happens regardless of resizing, since append() at best modifies the array that *ref/v points to, but it does not modify *ref/v itself; and slices in Go have a pointer to an underlying storage AND a start and end index into that storage (multiple slices can point to different parts of the same storage). Created here an example that shows how this interacts with resizing: https://play.golang.org/p/UJ-t63bKyJJ |
|