当前位置:网站首页>2022-07-24:以下go语言代码输出什么?A:[]int{};B:[]int(nil);C:panic;D:编译错误。 package main import ( “fmt“ ) f
2022-07-24:以下go语言代码输出什么?A:[]int{};B:[]int(nil);C:panic;D:编译错误。 package main import ( “fmt“ ) f
2022-07-25 04:49:00 【福大大架构师每日一题】
2022-07-24:以下go语言代码输出什么?A:[]int{};B:[]int(nil);C:panic;D:编译错误。
package main
import (
"fmt"
)
func f(a ...int) {
fmt.Printf("%#v\n", a)
}
func main() {
f()
}
答案选B,但却有 58% 的用户选的 A。首先,a 的类型是 []int,调用 f 时,没有传递任何参数,因此相当于值是 nil,即 a 的类型是 []int,值是 nil。而 fmt.Printf 的动词 %#v 会同时打印类型和值。所以结果是 B。
边栏推荐
- ES6 -- Methods and extensions of array objects, traversal of arrays, and extension methods of strings
- Compile ue5.0
- 小红书携手HMS Core,畅玩高清视界,种草美好生活
- The 6th "Blue Hat Cup" National College Students' Cyber Security Skills Competition writeup
- Now the operator wants to check the answer details of all user questions from Zhejiang University. Please take out the corresponding data
- Androd releases jitpack open source project (gradle7.2)
- When image component in wechat applet is used as background picture
- ThreadLocal Kills 11 consecutive questions
- 市场是对的
- Luogu p4281 [ahoi2008] emergency gathering / gathering solution
猜你喜欢

Implementation of recommendation system collaborative filtering in spark

Summary of UPR optimization suggestions of unity
![[sht30 temperature and humidity display based on STM32F103]](/img/43/bbc66ab2d56cfa9dc05d795e8fe456.jpg)
[sht30 temperature and humidity display based on STM32F103]

Ora-01460: conversion request cannot be implemented or unreasonable

MongoDB的安全认证详解

The strongest JVM in the whole network is coming!

Introduction to CpG control network
![Introduction to fundamentals of operations research [1]](/img/79/b613bff74a78ad63f202b9e652220d.png)
Introduction to fundamentals of operations research [1]

Ownership in rust -- introduction of rust language Xiaobai 11

It we media shows off its wealth in a high profile, and is targeted by hacker organizations. It is bound to be imprisoned
随机推荐
85 distributed project construction
When we talk about immutable infrastructure, what are we talking about
自然的状态最好
Json.tojsonstring cannot pass Boolean
How can test / development programmers with 5 years of experience break through the technical bottleneck? Common problems in big factories
Getting started with scratch
Summary and Prospect of aut, the transport layer protocol of sound network -- dev for dev column
Analysis of lottery winning numbers in history
It we media shows off its wealth in a high profile, and is targeted by hacker organizations. It is bound to be imprisoned
Li Kou 731. My schedule II
Libenent and libev
Blog Description & message board
小说抓取实战
PyG搭建GCN实现链接预测
Burpsuite爆破之token值替换
Ownership in rust -- introduction of rust language Xiaobai 11
MongoDB的安全认证详解
市场是对的
Summary of UPR optimization suggestions of unity
Androd releases jitpack open source project (gradle7.2)