mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2025-10-27 16:41:36 +00:00
ch6: fix code format
This commit is contained in:
@@ -68,15 +68,15 @@ func (p Point) Sub(q Point) Point { return Point{p.X - q.X, p.Y - q.Y} }
|
||||
type Path []Point
|
||||
|
||||
func (path Path) TranslateBy(offset Point, add bool) {
|
||||
var op func(p, q Point) Point
|
||||
if add {
|
||||
op = Point.Add
|
||||
} else {
|
||||
op = Point.Sub
|
||||
}
|
||||
for i := range path {
|
||||
// Call either path[i].Add(offset) or path[i].Sub(offset).
|
||||
path[i] = op(path[i], offset)
|
||||
}
|
||||
var op func(p, q Point) Point
|
||||
if add {
|
||||
op = Point.Add
|
||||
} else {
|
||||
op = Point.Sub
|
||||
}
|
||||
for i := range path {
|
||||
// Call either path[i].Add(offset) or path[i].Sub(offset).
|
||||
path[i] = op(path[i], offset)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user