PacktPublishing / Go-Design-Patterns

This is the code repository for the book, Go Design Patterns, published by Packt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

code page 22 closures

LucaPaterlini opened this issue · comments

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)
}`