This commit is contained in:
a.pivkin 2026-01-04 19:16:49 +03:00
parent 204c4c783f
commit 8aceabf0f1

View File

@ -2,18 +2,19 @@ package main
import "fmt" import "fmt"
func square() func () int { type Point struct {
var x int x int
return func() int {
x++
return x*x
} }
func (p *Point) Inc() {
p.x++
} }
func main() { func main() {
f := square() points := []*Point{{1},{2},{3}}
fmt.Println(f())
fmt.Println(f()) for _,p := range points {
fmt.Println(f()) p.Inc()
fmt.Println(f()) }
fmt.Println(f()) fmt.Println(points[0].x)
} }