Hi !
Why is this valid
a := [5]int{}
s := a[:0]
but this isn't
s := [5]int{}[:0]
I also tried this but it doesn't work either
s := ([5]int{})[:0]
? It says "slice of unaddressable value". Isn't a slice a strong reference, which would make the value addressable?

· · Mastodon Twitter Crossposter · 2 · 0 · 0
Here it says "Slice expressions construct a substring or slice from a string, array, pointer to array, or slice"

Interestingly, the following _does_ work!
b := (&[5]int{})[:]

Show thread
Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!