← Back to archive

Stdle #117 · slices · 2026-10-01

What does this Go snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

package main
import "fmt"
func main() {
a := []int{0, 1, 2, 3, 4, 5}
b := a[2:4]
fmt.Println(len(b), cap(b))
c := b[:cap(b)]
fmt.Println(c)
}
Slices
2 lines
4 attempts left

Answer & explanation