Interesting. I have never used var this way. I am the student here. (as in 
everything else!)

 

From: Axel Wagner <axel.wagner...@googlemail.com>
Date: Wednesday, October 19, 2016 at 2:39 PM
To: Michael Jones <michael.jo...@gmail.com>
Cc: Ian Lance Taylor <i...@golang.org>, T L <tapir....@gmail.com>, golang-nuts 
<golang-nuts@googlegroups.com>
Subject: Re: [go-nuts] Are short variable declarations necessary?

 

var could do that too:

https://play.golang.org/p/v9pQSZPTh_

(not that I'm advocating in favor of var in more places)

 

On Wed, Oct 19, 2016 at 11:17 PM, Michael Jones <michael.jo...@gmail.com> wrote:

In fact, this example hints at something important. You could do as you say and 
create variables of *different* types which I find very general compared to the 
suggested var feature:

for a, b, c := 0, 0.5, big.NewFloat(0.5).SetPrec(200); a < 15; a++ {

(https://play.golang.org/p/OM7OC3R949)

-----Original Message-----
From: <golang-nuts@googlegroups.com> on behalf of Ian Lance Taylor 
<i...@golang.org>
Date: Wednesday, October 19, 2016 at 12:25 PM
To: Michael Jones <michael.jo...@gmail.com>
Cc: T L <tapir....@gmail.com>, golang-nuts <golang-nuts@googlegroups.com>
Subject: Re: [go-nuts] Are short variable declarations necessary?

    You can create multiple local variables in the for scope by writing, for 
example
        for a, b := 0, 10; a < b; a++ {
    (That would work with var, too).

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to