Go Short Variable Declaration Invalid Cases: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
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=

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 :=