Go Multiple Variable Assignment
package main
import (
"fmt"
)
func main() {
var d, e int
d = 8
e = 9
fmt.Printf("These were declared in single line then assigned values later: %v %v\n", d,e)
var (
a=5
b=6
c=7
)
fmt.Printf("These were declared and assigned values using a multi-line group: %v %v %v\n", a,b,c)
f := 10
g := 11
fmt.Printf("These were declared and assigned values using := : %v %v\n", f,g)
var h, i = 12, 13
fmt.Printf("These were declared and assigned values in single line: %v %v\n", h,i)
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎