Variables with initializers
You can initialize variables right in the var declaration. When you do, the type is optional — Go infers it from the value you provide.
You can initialize variables right in the var declaration. When you do, the type is optional — Go infers it from the value you provide.
package main
import "fmt"
var i, j int = 1, 2
func main() {
var c, python, java = true, false, "no!"
fmt.Println(i, j, c, python, java)
} ← → Use arrow keys to navigate