当前位置:网站首页>go语言:在函数间传递切片
go语言:在函数间传递切片
2022-04-23 06:15:00 【玩哈哈527】
package main
import "fmt"
//在函数间传递切片
func main() {
// 分配包含 10个整型值的切片
slice:= make([]int, 10)
// 将 slice 传递到函数 foo
var slice1 []int
slice1= foo(slice)
// 函数 foo 接收一个整型切片,并返回这个切片
fmt.Print(slice1)
}
func foo(slice []int) []int {
slice=append(slice,3)//给切片追加一个元素3
return slice
}
/* 打印输出结果 [0 0 0 0 0 0 0 0 0 0 3] */
版权声明
本文为[玩哈哈527]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_28058509/article/details/119213374
边栏推荐
- Chapter 8 generative deep learning
- 自组网灵活补盲|北峰油气田勘测解决方案
- Chapter 2 pytoch foundation 1
- PyTorch 21. PyTorch中nn.Embedding模块
- 防汛救灾应急通信系统
- 机器学习——PCA与LDA
- 【指标】Precision、Recall
- PyTorch 22. PyTorch常用代码段合集
- [point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation
- 直观理解 torch.nn.Unfold
猜你喜欢
随机推荐
FATFS FAT32学习小记
PyTorch 20. PyTorch技巧(持续更新)
基于open mv 搭配stm32循迹
SPI NAND FLASH小结
Common regular expressions
美摄科技云剪辑,助力哔哩哔哩使用体验再升级
Use originpro express for free
PyTorch 19. PyTorch中相似操作的区别与联系
unhandled system error, NCCL version 2.7.8
AUTOSAR从入门到精通100讲(五十二)-诊断和通信管理功能单元
STM32多路测温无线传输报警系统设计(工业定时测温/机舱温度定时检测等)
Chapter 5 fundamentals of machine learning
项目文件“ ”已被重命名或已不在解决方案中、未能找到与解决方案关联的源代码管理提供程序——两个工程问题
ARMCC/GCC下的stack protector
PyTorch 22. PyTorch常用代码段合集
PyTorch 12. hook的用法
带低压报警的51单片机太阳能充电宝设计与制作(完整代码资料)
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
Draw margin curve in arcface
PyTorch 10. Learning rate









