Kotlin top-levels functions vs object function

前端 未结 5 1475
余生分开走
余生分开走 2021-01-19 01:20

I have static function which is limited to some context eg only for docs. There are 2 alternative ways to define it as top-level function or function in an object.

1

5条回答
  •  抹茶落季
    2021-01-19 01:54

    The recommended practice is to never use object for creating namespaces, and to always use top-level declarations when possible. We haven’t found name conflicts to be an issue, and if you do get a conflict, you can resolve it using an import with alias.

提交回复
热议问题