This commit is contained in:
github-actions[bot]
2022-10-20 06:05:49 +00:00
parent 441913e7e5
commit 293c16fd2d
5 changed files with 6 additions and 6 deletions

View File

@@ -224,7 +224,7 @@ perim := geometry.Path{{1, 1}, {5, 1}, {5, 4}, {1, 1}}
fmt.Println(geometry.PathDistance(perim)) // "12", standalone function
fmt.Println(perim.Distance()) // "12", method of geometry.Path
</code></pre>
<p><strong>译注:</strong> 如果我们要用方法去计算perim的distance还需要去写全geometry的包名和其函数名但是因为Path这个类型定义了一个可以直接用的Distance方法所以我们可以直接写perim.Distance()。相当于可以少打很多字作者应该是这个意思。因为在Go里包外调用函数需要带上包名还是挺麻烦的。</p>
<p><strong>译注:</strong> 如果我们要用函数去计算perim的distance还需要去写全geometry的包名和其函数名但是因为Path这个类型定义了一个可以直接用的Distance方法所以我们可以直接写perim.Distance()。相当于可以少打很多字作者应该是这个意思。因为在Go里包外调用函数需要带上包名还是挺麻烦的。</p>
<!-- 公众号 -->