你可以在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.

是的,您可以:

Yes, you can:

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