20 lines
207 B
Go
20 lines
207 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type Point struct {
|
|
x int
|
|
}
|
|
|
|
func (p *Point) Inc() {
|
|
p.x++
|
|
}
|
|
|
|
func main() {
|
|
points := []*Point{{1},{2},{3}}
|
|
|
|
for _,p := range points {
|
|
p.Inc()
|
|
}
|
|
fmt.Println(points[0].x)
|
|
} |