2 ms·
Sure. The only thing that was obscure to me in the beginning was slices. I could not comprehend at first that an append could modify the underlying and possibly
by tgv 6y ago
Sure. The only thing that was obscure to me in the beginning was slices. I could not comprehend at first that an append could modify the underlying and possibly aliased data structure, and other slices. I blame the pseudo-functional use, x = append(x, ...), and the fact that taking a slice looks so much like making a copy for that. It simply deviated too much from all the other languages I've programmed in.
- mappu 6y agoIt's following C: x = realloc(x, ...)
- everybodyknows 6y agoSame here. I found it helpful to bear in mind that y := append(x, ...), while seldom wanted, is legal.