gpt4 book ai didi

go - := mean in Go? 是什么

转载 作者:IT王子 更新时间:2023-10-29 01:15:54 24 4
gpt4 key购买 nike

我正在学习本教程,特别是练习 8:

http://tour.golang.org/#8


package main

import "fmt"

func swap(x, y string) (string, string) {
return y, x
}

func main() {
a, b := swap("hello", "world")
fmt.Println(a, b)
}

:= 具体是什么意思?具有讽刺意味的是,搜索 Go 文档非常困难。

最佳答案

A short variable declaration使用语法:

ShortVarDecl = IdentifierList ":=" ExpressionList .

它是带有初始化表达式但没有类型的常规变量声明的简写:

关于go - := mean in Go? 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16577601/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com