Hi everyone!
Please help me figure out the two different results of following code:

package main
import (
    "fmt"
    "time"
)
func main() {
    var num = 10
    var p = &num

    c := make(chan int)

    go func() {
        c <- *p // with this line we will get 11 from channel c
        //c <- num // with this line we will get 10 from channel c
    }()

    time.Sleep(2 * time.Second)
    num++
    fmt.Println(<-c)

    fmt.Println(p)
}

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