On Tue, Mar 21, 2017 at 5:38 PM, WinD zz <[email protected]> wrote: > > func main() { > const abc = 111 > fmt.Printf("%t\n", abc) > fmt.Println(math.Pi * abc) > fmt.Printf("%t", math.Pi) > } > > result: > %!t(int=111) > 25.132741228718345 > %!t(float64=3.141592653589793) > > func main() { > const abc int = 111 > fmt.Printf("%t\n", abc) > fmt.Println(math.Pi * abc) > fmt.Printf("%t", math.Pi) > } > > result: > constant 3.14159 truncated to integer > > Why when i typed abc int ,the compiler will error. > But,first example tell me on runtime the abc type is int. > > this is why?
https://golang.org/blog/constants Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
