From 8aceabf0f1be3a4d420ddf7e3772786879426b4b Mon Sep 17 00:00:00 2001 From: "a.pivkin" Date: Sun, 4 Jan 2026 19:16:49 +0300 Subject: [PATCH] ret --- book_with_bridge/comon_shit/main.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/book_with_bridge/comon_shit/main.go b/book_with_bridge/comon_shit/main.go index 9613ee0..d6d0230 100644 --- a/book_with_bridge/comon_shit/main.go +++ b/book_with_bridge/comon_shit/main.go @@ -2,18 +2,19 @@ package main import "fmt" -func square() func () int { - var x int - return func() int { - x++ - return x*x - } +type Point struct { + x int } + +func (p *Point) Inc() { + p.x++ +} + func main() { - f := square() - fmt.Println(f()) - fmt.Println(f()) - fmt.Println(f()) - fmt.Println(f()) - fmt.Println(f()) + points := []*Point{{1},{2},{3}} + + for _,p := range points { + p.Inc() + } + fmt.Println(points[0].x) } \ No newline at end of file