golang:slice切片

一直对slice切片这个概念理解的不是太透彻,之前学习python的就没搞清楚,不过平时就用python写个工具啥的,也没把这个当回事去花时间解决。

最近使用go开发又遇到这个问题,于是打算彻底把这个概念搞清楚,阅读了几篇文章,记录下自己对切片的理解:

https://blog.golang.org/slices

这篇文章里面有一段这样的话,我认为算是对slice做出了一个简单明确的定义:

 A slice is a data structure describing a contiguous section of an array stored separately from the slice variable itself. A slice is not an array. A slice describes a piece of an array.
slice是一个描述了存储在其他地方的数组中的一段连续数据的数据结构。slice不是一个数组。slice描述了一个数组的一部分。
 
这里让我想起了数据库中的视图概念,视图只是定义了一个数据集,但是它不存储数据,实际数据在其他表中存储。
 
 

猜你喜欢

转载自www.cnblogs.com/lit10050528/p/8946472.html