Hacker News new | ask | show | jobs
by nixarn 4997 days ago
Quick Go question. I haven't done much go coding at all, but play around with the language. I've been reading a lot about it (thanks to HN). So I was now looking at the Slices section and noticed a slice being initalize as:

t := []int{1, 2, 3, 4, 5}

What makes that a slice and not an array?

EDIT: Ok, found that answer on google go's blog. Apparently leaving out the length makes it one.

1 comments

Arrays are a fixed size. eg. t:=[5]int{1,2,3,4,5}

Go can also do the counting for you. eg. t:=[...]int{1,2,3,4,5}

Oh, nice, thanks!