Can you declare multiple variables at once in Go?

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

    Try this in the go-playground: https://play.golang.org/

    package main
    
    import "fmt"
    
    func main() {
        a, b := "a", "b"; //Declare And Assign
        var c, d string;  //Declare Only
        fmt.Println(a,b);
        fmt.Println(c,d);
    }
    

提交回复
热议问题