Can you declare multiple variables at once in Go?

前端 未结 6 1135
鱼传尺愫
鱼传尺愫 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:07

    Another way of doing is using var for package level assignment

    package main
    
    import (
        "fmt"
    )
    
    var (
        a, b, c = 80, 80 ,80
    )
    
    func main() {
        fmt.Println(a, b, c)
    }
    

提交回复
热议问题