你可以在 Go 中一次声明多个变量吗? [英] Can you declare multiple variables at once in Go?
本文介绍了你可以在 Go 中一次声明多个变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用 Golang 一次声明多个变量?
Is it possible to declare multiple variables at once using Golang?
例如在 Python 中,您可以输入:
For example in Python you can type this:
a = b = c = 80
并且所有值都是 80.
and all values will be 80.
推荐答案
是的,您可以:
var a, b, c string
a = "foo"
fmt.Println(a)
你可以为内联赋值做一些类似的事情,但不太方便:
You can do something sort of similar for inline assignment, but not quite as convenient:
a, b, c := 80, 80, 80
这篇关于你可以在 Go 中一次声明多个变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文