// Much the same as clos1, but in this case change the value of // ii (which is in the closure of the function a) AFTER the function // is created. // The point here is that the change is reflected in the closure. That is, // the closure does not contain copies of var, it contains the vars // // Author: GTowell // Created: August, 2021 package main import "fmt" type Clo1 func(int) func main() { ff := makefun(100) ff(7) ff(7) } func makefun(ii int) Clo1 { a := func(bb int) { fmt.Printf("FUNC: %d\n", (ii+bb)) } ii*=2; return a }