code page 22 closures
LucaPaterlini opened this issue · 0 comments
LucaPaterlini commented
this code does not compile
func main() { addN := func(m int) { return func(n int) { return m + n } } addFive := addN(5) result := addN(6) //5 + 6 must print 7 println(result) }
This one compiles and has the expected behaviour
Advice: add the working code in chapter one repo
`package main
import "fmt"
func main(){
addN := func(m int)func(int)int{
return func(n int)int{
return m+n
}
}
addFive := addN(5)
result := addFive(6)
fmt.Println(result)
}`