英文:
A Go slice holds a reference to a subsection of an array or just a single element?
问题
将切片视为一个小的数据结构,它有两个元素:长度和指向数组元素的指针。
对于说“...指向数组元素的指针”的措辞感到有些困惑。只有当切片的len()为1时,才会是这种情况,对吗?
我认为博客文章可能是想说它是指向数组的“子部分”的指针,对吗?
英文:
Golang blog about slices and arrays
> think of a slice as a little data structure with two elements: a length and a pointer to an element of an array.
Little bewildered by verbiage saying: '...pointer to an ELEMENT of an array.' That would only be the case if it was a slice with len() of 1, right?
I believe the blog post may have meant to say that it was a pointer to a 'subsection' of an array, right?
答案1
得分: 1
是的,这是指向底层数组中第一个切片元素的指针。我敢打赌这个措辞来自Go语言的C背景
英文:
Yes, a pointer to the first slice element in the backing array. I bet this wording comes from Go language C background
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论