当前位置:网站首页>2022-07-16:以下go语言代码输出什么?A:[];B:[5];C:[5 0 0 0 0];D:[0 0 0 0 0]。 package main import ( “fmt“ )
2022-07-16:以下go语言代码输出什么?A:[];B:[5];C:[5 0 0 0 0];D:[0 0 0 0 0]。 package main import ( “fmt“ )
2022-07-17 00:33:00 【福大大架构师每日一题】
2022-07-16:以下go语言代码输出什么?A:[];B:[5];C:[5 0 0 0 0];D:[0 0 0 0 0]。
package main
import (
"fmt"
)
func main() {
a := make([]int, 0, 5)
addElem(a, 5)
fmt.Println(a)
}
func addElem(a []int, i int) {
a = append(a, 5)
}
答案选A。可以简单的理解切片本身是结构体,参数传递只是结构体复制传递。切片在大多数情况下,只能修改元素,不能删除或者新增元素。

边栏推荐
猜你喜欢
随机推荐
多表查询——案例练习
C language foundation day4 array
当你在Linux系统中编译安装MySQL数据库卡住了怎么办?
Full virtualization and semi virtualization
[MCU simulation] (XV) instruction system bit operation instructions - bit operation instructions, bit conditional transfer instructions
【单片机仿真】(十三)指令系统逻辑运算指令 — 移位指令
多锻炼身体有好处
ncnn DataReader&Extractor&blob
Letv a plus de 400 employés? Le jour de l'immortel sans patron, les autorités ont répondu...
05-中央处理器
仿射变换实现
yolov5 opencv DNN 推理
【单片机仿真】(八)指令系统 — 数据传送指令
【单片机仿真】(二十一)DB(Define Byte)— 定义字节
Oracle查询时间段内所有日期
[redis] what is progressive rehash
[regression prediction] lithium ion battery life prediction based on particle filter with matlab code
【单片机仿真】(二十)ORG — 设置起始地址
Configure VLAN and use OSPF protocol for layer 3 switches
【单片机仿真】(十四)指令系统位操作类指令 — 位数据传送指令MOV、位变量修改指令









