mhilmi
(mohammed)
December 4, 2018, 9:53pm
1
Hello,
https://golang.org/ref/spec#Constant_declarations
According to the grammar defined in the link above, the statement ‘const toto’ could compile (or in other words, is idiomatic) . This is wrong and thanks God the Golang indeed throw a compilation error.
Regards,
It is valid if it comes after another declaration. See these examples
https://play.golang.org/p/VCMAQzEulkJ
and
https://play.golang.org/p/tNJUYkP0Gsm
2 Likes
mhilmi
(mohammed)
December 5, 2018, 10:22am
3
Yes, indeed.
But, like I said, the statement “const toto” is considered valid based on the grammar, which is wrong in practice.
https://play.golang.org/p/Il6Rk-SqzaS
This snippet is not working, but the constant_declartions section says it’s valid.
system
(system)
Closed
March 5, 2019, 10:35am
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.