1 // expected: pop is a statement: it removes the last element; read it with s[len(s)-1]
2 //
3 // pop removes and returns nothing usable. The old expression form returned the
4 // element WITHOUT shrinking, so `v := pop(s)` and `pop(s)` meant two different
5 // things depending on whether the value was used - a footgun, not a feature.
6 // The read is `s[len(s)-1]` and the copy is `s[len(s)-1:]`; both are plain
7 // expressions with the same empty-slice panic.
8 package main
9 10 func main() {
11 select {
12 case <-shutdown:
13 return
14 default:
15 }
16 s := []int32{1, 2, 3}
17 v := pop(s)
18 println(v)
19 }
20