当前位置:网站首页>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。可以简单的理解切片本身是结构体,参数传递只是结构体复制传递。切片在大多数情况下,只能修改元素,不能删除或者新增元素。

边栏推荐
猜你喜欢

Multi layer packet structure and TCP triple handshake

MySQL master-slave replication + read write separation

Understand JVM garbage collection in one article

Systick timer basic learning and hand tearing code

ELK日志分析系统

Tools and methods - Excel plug-in xltools

From the perspective of MySQL architecture, how does an SQL statement execute?

HCIA_ Rip experiment

C语言基础Day4-数组

ResNet学习笔记
随机推荐
需要慢一点点
BiSeNetV2-面部分割
DHCP service
From the perspective of MySQL architecture, how does an SQL statement execute?
[MCU simulation] (VII) addressing mode - bit addressing
RESNET learning notes
3. Asynctool framework principle source code analysis
【单片机仿真】(二十一)DB(Define Byte)— 定义字节
深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之SMOTE采样法及Borderline-SMOTE采样法]
DDD 超越 MVC了吗
RHCE ansible first operation
Oracle获取最后一条,第一条数据(按时间获取第一条和最后一条数据)
4. Some thoughts on asynctool framework
yolov5 ncnn 推理
5. Is the asynctool framework flawed?
C language foundation day4 array
Go language realizes sending SMS verification code and logging in
【单片机仿真】(十八)控制转移类指令 — 空操作指令
[single chip microcomputer simulation] (XI) instruction system logic operation instruction - logic and instruction anl, logic or instruction ORL
mysqldump: [Warning] Using a password on the command line interface can be insecure.