In Kotlin, a function with at least one argument can be defined either as a regular non-member function or as an extension function with one argument being a receiver.
As to the scoping, there seems to be no difference: both can be declared inside or outside classes and other functions, and both can or cannot have visibility modifiers equally.
语言参考似乎不建议在不同的情况下使用常规函数或扩展函数.
所以,我的问题是:when do extension functions give advantage over regular non-member ones?,当常规的超过扩展时?
foo.bar(baz, baq)
vs bar(foo, baz, baq)
.
这仅仅是函数语义的一个暗示(接收者绝对是关注焦点),还是在某些情况下,使用扩展函数会使代码更简洁,或者打开机会?