When you
initialize a variable without specifying type, then the type of the variable is
inferred from the value on the right hand side.
App.go
package main import "fmt" func main() { i := 10 j := 10.23 k := true l := "Hello World" fmt.Printf("i is of type %T\n", i) fmt.Printf("j is of type %T\n", j) fmt.Printf("k is of type %T\n", k) fmt.Printf("l is of type %T\n", l) }
Output
i is of
type int
j is of
type float64
k is of
type bool
l is of
type string
No comments:
Post a Comment