Hi all,

I still consider myself a newbie to Golang hence my question here could be 
due to my fundamental misunderstanding of this language

I have the following code:

func main() {

    for i := 0; i < 5; i++ {

        go func() {

            log.Println("i=", i)

        }()

    }


    fmt.Print("Press <Enter> to quit...")

    var input string

    fmt.Scanln(&input)

}


The output I expect is 0, 1, 2, 3, and 4 in any jumbled order.  But what I 
got was 5, 5, 5, 5 and 5!  Why is that so?

Thanks in advance

rgds,
Vatsan

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