18 lines
198 B
Go
18 lines
198 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func square() func() int {
|
|
var x int
|
|
return func() int{
|
|
x++
|
|
return x*x
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
f := square()
|
|
fmt.Println(f())
|
|
fmt.Println(f())
|
|
fmt.Println(f())
|
|
} |