true is an expression, the compiler doesn’t inspect that it is a constant 
expression, thus you need the return statement

> On Oct 11, 2024, at 4:57 PM, Pierpaolo Bernardi <olopie...@gmail.com> wrote:
> 
> Hello,
> 
> the following code works as I expect: https://go.dev/play/p/pjKqpZyTU0d
> 
> However, if I change line 15 from
> 
> for i := 0; ; i++ {
> 
> to
> 
> for i := 0; true; i++ {
> 
> it does not compile. In my understanding the two should be equivalent,
> but they are not. Maybe I'm missing a simple explanation?
> 
> -- 
> 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 golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CANY8u7F3pV_FX3jQHRz%2BOpmrPN0qb6-2-NAwzQYNRe9Qq18D8A%40mail.gmail.com.

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0E9E12CB-EF17-4977-BA5A-07704C01DAB9%40ix.netcom.com.

Reply via email to