当前位置:网站首页>《Go题库·12》slice和array区别?
《Go题库·12》slice和array区别?
2022-06-28 02:31:00 【GolangRoadmap】
*「题目解析」GOLANG ROADMAP社区
*
「答案」(engine)
array是固定长度的数组,是值类型的,如果进行赋值或者作为函数参数,实际上整个数据都会被重新拷贝一份。
使用前必须声明长度
arr := [5]int
而slice属于引用类型,是一个不定长的,总是指向底层的数组array的数据结构。作为函数参数时,slice传递的是指针。
创建时不需要指定长度
var s []int
s := make([]int,10)
s :=[]int{1,2,3}
边栏推荐
猜你喜欢
随机推荐
[522. longest special sequence II]
RichView TRVStyle
Tencent games released more than 40 products and projects, including 12 new games
RichView TRVStyle TextStyles
调试利器 go-spew
栈的基本操作(C语言实现)
Question bank and answers of special operation certificate for R1 quick opening pressure vessel operation in 2022
17 `bs对象.节点名h3.parent` parents 获取父节点 祖先节点
业内首个!可运行在移动设备端的视频画质主观体验MOS分评估模型!
2022危险化学品经营单位安全管理人员特种作业证考试题库模拟考试平台操作
导致系统性能失败的十个原因
Tardigrade: Trino's solution to ETL scenarios
第二轮红队免费公开课来袭~明晚八点!
Notepad++--列编辑模式--用法/实例
Apache——阿帕奇簡介
Gateway microservice routing failed to load microservice static resources
The same is MB. Why is the gap so large?
Brief history and future trend of codeless software
2022安全员-C证考试题库模拟考试平台操作
2022 operation of simulated examination platform of special operation certificate examination question bank for safety management personnel of hazardous chemical business units









