patterngoCritical
Can you declare multiple variables at once in Go?
Viewed 0 times
variablesyouoncedeclaremultiplecan
Problem
Is it possible to declare multiple variables at once using Golang?
For example in Python you can type this:
and all values will be 80.
For example in Python you can type this:
a = b = c = 80and all values will be 80.
Solution
Yes, you can:
You can do something sort of similar for inline assignment, but not quite as convenient:
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, 80Code Snippets
var a, b, c string
a = "foo"
fmt.Println(a)a, b, c := 80, 80, 80Context
Stack Overflow Q#21071507, score: 146
Revisions (0)
No revisions yet.