Re: [go-nuts] Constants

2018-12-16 Thread Ian Lance Taylor
On Sun, Dec 16, 2018 at 6:15 PM 伊藤和也 wrote: > > Can I say the type of the integer constant "12" is converted from the default > type "int" to "int32" when it is assigned to the constant "n1" whose type is > "int32" ? > > const n1 int32 = 12 > > Go programmimg language specification says "An unt

[go-nuts] Constants

2018-12-16 Thread 伊藤和也
Can I say the type of the integer constant "12" is converted from the default type "int" to "int32" when it is assigned to the constant "n1" whose type is "int32" ? const n1 int32 = 12 Go programmimg language specification says "An untyped constant has a *default type* which is the type to wh

Re: [go-nuts] constants vs variables

2017-07-08 Thread Shawn Milochik
https://blog.golang.org/constants This explains why you can do stuff like that and why the Go team decided to make the language work this way. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emai

[go-nuts] constants vs variables

2017-07-08 Thread Alexey Dvoretskiy
Hello golang-nuts, Here are two code snippets with operations on different types. One with constants and another one with variables. The first one works, the second one doesn't. Why is it like this? Logically both code snippets shouldn't work: https://play.golang.org/p/eqNJootZ3a package main