3 ms·
> [Go lacks] nested functions with access to variables in their enclosing scope Surely Go has this? func main() { a := 1 func() { b := a g := func() {
by xyproto 8y ago
> [Go lacks] nested functions with access to variables in their enclosing scope
Surely Go has this?
func main() {
a := 1
func() {
b := a
g := func() {
c := b
fmt.Println("c is", c)
a = 7
}
g()
}()
fmt.Println("a is now", a)
}
https://play.golang.org/p/zmWwCNm_PuU https://play.golang.org/p/zmWwCNm_PuU