Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardGoslice header aliasing pitfallsSingle-choice MCQ

Why can a full-slice (three-index) expression like `s[low:high:max]` prevent a subtle aliasing bug that `s[low:high]` would cause?

base := make([]int, 2, 8) x := base[0:2:2] // cap capped to 2 y := append(x, 7) // forced to reallocate _ = y fmt.Println(len(base))