On Tue, Jan 9, 2018 at 10:08 PM Jim Bishopp wrote:
> Has there ever been a discussion about allowing new identifiers and
selectors in short variable declarations?
FTR: There are other things that are legal on the LHS of an assignment, but
not in the short variable declaration, like x[i], *x, *f(
This works:
b, a := 1, struct{ x int }{2}
But this doesn’t:
var a struct{ x int }
b, a.x := Returns1And2()
But this does:
var a struct{ x int }
var b int
b, a.x = Returns1And2()
And this does:
var a int
b, a := Returns1And2()
Matt
On Tuesday, January 9, 2018 at 5:59:49 PM UTC-6, Kevin Mala
It is not a new declaration, it is definitely an assignment. This can be
determined because (in Go) a new declaration has effects when closing over
variables: https://play.golang.org/p/a_IZdOWeqYf
(ignore the obvious race condition; it works the same but looks uglier with
the requisite locks: h
On 01/09/2018 04:45 PM, Ian Lance Taylor wrote:
> On Tue, Jan 9, 2018 at 1:02 PM, Jim Bishopp
> wrote:
>>
>> Has there ever been a discussion about allowing new identifiers and
>> selectors in short variable declarations?
>>
>> var a struct { x int } b, a.x := 1, 2
>>
>> ERROR: expected ident
On Tue, Jan 9, 2018 at 1:02 PM, Jim Bishopp wrote:
>
> Has there ever been a discussion about allowing new identifiers and
> selectors in short variable declarations?
>
> var a struct { x int }
> b, a.x := 1, 2
>
> ERROR: expected identifier on left side of :=
That idea appears in https://golang.
Has there ever been a discussion about allowing new identifiers *and
selectors *in short variable declarations?
var a struct { x int }
b, a.x := 1, 2
ERROR: expected identifier on left side of :=
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" grou