为什么len是函数而不是方法

原创
2016/05/27 16:28
阅读数 193

Why is len a function and not a method?

为什么len是函数而不是方法?

We debated this issue but decided implementing len and friends as functions was fine in practice and didn't complicate questions about the interface (in the Go type sense) of basic types.

我们经过反复讨论决定这样做的。len作为函数在具体操作中更友好。这样做,还有一个好处,我们不至于为了实现Go的基本类型的len方法,而去搞基本类型的接口实现。

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部