The following code:

package main

import "fmt"

func main() {
    var i int
    fmt.Println(i)
    if true {
        i = 5
        i, j := 3, 4
        fmt.Println(i, j)
    }
    fmt.Println(i)
}

Output:
0
3 4
5

Is this a reasonable behavior? I intuitively thought only j is declared in 
if block and i will be the same as outer one.

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