4 ms·
Exactly. The inadvertent aliasing can produce situations like this: https://play.golang.org/p/XUtyQ6ShYaz https://play.golang.org/p/XUtyQ6ShYaz , or more plausi
by mappu 9y ago
Exactly. The inadvertent aliasing can produce situations like this: https://play.golang.org/p/XUtyQ6ShYaz https://play.golang.org/p/XUtyQ6ShYaz , or more plausibly: https://play.golang.org/p/Xx8lZWVWgIu https://play.golang.org/p/Xx8lZWVWgIu
- innagadadavida 9y agoThanks for this. It gets weirder! The slice grows/doubles if capacity is insufficient. So if you initialize the original slice all the way to capacity (len=4, cap=4), it works correctly. But if len=3 and cap=4, it shows bad behavior. https://play.golang.org/p/qf3lAoin4dM https://play.golang.org/p/qf3lAoin4dM