Understanding variable scope in Go

前端 未结 2 1636
梦谈多话
梦谈多话 2021-01-12 10:06

I am going through the Go specification to learn the language, and these points are taken from the spec under Declarations and scope.

Though I am able t

2条回答
  •  無奈伤痛
    2021-01-12 10:32

    They're making the same point, with the same rules, about two different things: the first is about variables and constants, the second is about type identifiers. So, if you declare a type inside a block, the same scoping rules apply as would apply to a variable declared at the same spot.

提交回复
热议问题