ch6/ch6-02 #172
Replies: 3 comments 1 reply
-
最后一段原文: |
Beta Was this translation helpful? Give feedback.
-
我按自己理解做个总结吧:(姑且用对象来做说明吧)
测试代码如下: type Number struct { func (n Number) Add(i int) Number { func (np *Number) AddbyPtr(i int) { func Test() {
} 运行结果: a: 1 b: 2 |
Beta Was this translation helpful? Give feedback.
-
这写的太乱了,还不如直接去搜:golang的值接收器与指针接收器 1、本质就是传值与传地址的区别
2、体现在这里主要区别就是:
3、那么就只需要考虑使用场景和使用注意点了1、使用场景
2、注意点
Point{1, 2}.ScaleBy(2) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
ch6/ch6-02
中文版
https://golang-china.github.io/gopl-zh/ch6/ch6-02.html
Beta Was this translation helpful? Give feedback.
All reactions