gpt4 book ai didi

go - 你能在 Go 中一次声明多个变量吗?

转载 作者:数据小太阳 更新时间:2023-10-29 03:21:27 24 4
gpt4 key购买 nike

是否可以使用 Golang 一次声明多个变量?

例如在 Python 中你可以这样输入:

a = b = c = 80

所有值都将为 80。

最佳答案

是的,你可以:

var a, b, c string
a = "foo"
fmt.Println(a)

您可以为内联赋值做一些类似的事情,但不是很方便:

a, b, c := 80, 80, 80

关于go - 你能在 Go 中一次声明多个变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53145619/

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