Re: [go-nuts] Not used var error

2022-01-18 Thread Paulo Júnior
Dear, Ian. You are correct and I was wondering why the reassignment did not work in the case of *x *var*. *I found the answer in the Effective Go documentation, in the *Redeclaration and reassignment* section: In a := declaration *a variable v may appear even if it has already been > declared*, *

Re: [go-nuts] Not used var error

2022-01-17 Thread Ian Lance Taylor
On Mon, Jan 17, 2022 at 7:07 PM Paulo Júnior wrote: > > I'm studying about if statement and comma ok construction and I'm not sure > why the piece of code (https://go.dev/play/p/ScFJsih6lwR) bellow does not > work. The compiler says that: x declared but not used. However, x is used in > the sec

[go-nuts] Not used var error

2022-01-17 Thread Paulo Júnior
Hi all. I'm studying about *if statement* and *comma ok construction* and I'm not sure why the piece of code (https://go.dev/play/p/ScFJsih6lwR) bellow does not work. The compiler says that: *x declared but not used*. However, *x* is used in the second *if statement *of the *main function*, as