On Wed, Jan 14, 2026 at 1:36 PM 'Brian Candler' via golang-nuts
<[email protected]> wrote:

> I'm having trouble understanding something in the go spec for short variable 
> (re)declarations.  The spec says:

I believe the code is the equivalent of
https://go.dev/play/p/y96Q3YWjI-y. Which fails the same way, but IMO
not/less surprisingly, because the second 'code' variable is declared
in a different scope than the first one.

And it is a separate block because the specs says
(https://go.dev/ref/spec#Blocks)

""""
4. Each "if", "for", and "switch" statement is considered to be in its
own implicit block.
""""

-j

-- 
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].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-Vd6xHMpHVzgzD-Em8hhgQvYyPwwunGcbDL6Mye9UpRKg%40mail.gmail.com.

Reply via email to