In golang closure func ,the needed outer variable is passed by reference 



<https://lh3.googleusercontent.com/-tEbwJf6Ff0w/WBqnDv1rAPI/AAAAAAAAAAg/D227zYDnnr0curBcNFFWf3uz9j8rS2fhwCLcB/s1600/closure.png>













but when the variable self is a reference in example.go , the closure func 
paras is *[&map[int]int,...]  is so ?

and I doubt what kind of datatype the paras in closure func?

// example.go

package main


import "time"


func main() {
 m := map[int]int{1: 100, 2: 200}
 println(&m, m)
 go func() {
 time.Sleep(1 * time.Second)
 println(m[1])
 }()
 m = map[int]int{3: 300, 4: 400}
 time.Sleep(2 * time.Second)
}

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