20 lines
212 B
Go
20 lines
212 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 i := range points {
|
|
points[i].Inc()
|
|
}
|
|
fmt.Println(points[0].x)
|
|
} |