Can you declare multiple variables at once in Go?

前端 未结 6 1245
鱼传尺愫
鱼传尺愫 2020-12-01 15:36

Is it possible to declare multiple variables at once using Golang?

For example in Python you can type this:

a = b = c = 80

and all

6条回答
  •  抹茶落季
    2020-12-01 16:22

    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
    

提交回复
热议问题