You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the variables are initialized with the expressions following the rules for assignments
in the variable declaration section, and
The blank identifier provides a way to ignore right-hand side values in an assignment
in the assignment section.
From this point of view, the variable declarations should probably work, though I'd say the spec is actually not clear on this.
Since the declarations work outside the function, and assignments (i.e. without "var") work inside the function, I understand that these kind of declarations are useless. This is just some weird interesting behaviors.
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Go playground
What did you do?
There will be no problems if we apply any one of the following changes:
{}
, e.g.var _ = map[int]int{}
can be compiled without any problem;var _ map[int]int = map[int]int{0: 0}
won't work.)See https://play.golang.org/p/UII6jcBRTUu.
What did you expect to see?
The spec mentions
in the variable declaration section, and
in the assignment section.
From this point of view, the variable declarations should probably work, though I'd say the spec is actually not clear on this.
Since the declarations work outside the function, and assignments (i.e. without "var") work inside the function, I understand that these kind of declarations are useless. This is just some weird interesting behaviors.
The text was updated successfully, but these errors were encountered: