Go Short Variable Declaration Invalid Cases: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[Go_Concepts_-_Lexical_Structure#Short_Variable_Declaration|Lexical Structure]] | * [[Go_Concepts_-_Lexical_Structure#Short_Variable_Declaration|Lexical Structure]] | ||
=With Package-Level Variables= | |||
<font color=red>'''TODO'''</font> | |||
=With Method Receivers' Fields= | =With Method Receivers' Fields= | ||
Line 13: | Line 17: | ||
func (a A) m(i int) { | func (a A) m(i int) { | ||
a.i := i + 1 // invalid | a.i := i + 1 // invalid | ||
} | } | ||
... | ... | ||
</pre> | |||
Compiler error: | |||
<pre> | |||
./main.go:12: non-name a.i on left side of := | |||
</pre> | </pre> |
Latest revision as of 10:59, 4 April 2016
Internal
With Package-Level Variables
TODO
With Method Receivers' Fields
... type A struct { i int } func (a A) m(i int) { a.i := i + 1 // invalid } ...
Compiler error:
./main.go:12: non-name a.i on left side of :=