Wikipedia: Closure
Tengo supports anonymous functions, which can form closures. Closures are functions that "capture" variables from their outer scope.
fmt := import("fmt")
intSeq := func() {
i := 0
return func() {
i++
return i
}
}
nextInt := intSeq()
fmt.println(nextInt())
fmt.println(nextInt())
fmt.println(nextInt())
newInts := intSeq()
fmt.println(newInts())
try it
1 2 3 1