Kotlin 中实用程序集合的首选文件命名约定是什么?
What is the preferred file naming convention in Kotlin for a utility collection?
作为 Kotlin 的新手,我不确定像下面这样的文件的正确名称是什么:
package de.company.carbase
import de.company.carbase.model.Car
typealias CarSupplier = () -> Car
我把它命名为cars-utils.kt
。仅使用小写字母并有意使用连字符将其与常规 class 文件区分开来。
这对我来说似乎没问题,但也许我错过了一个既定的约定?
文件的 Kotlin 命名约定与 class、对象、接口、枚举等相同
HelperUtil.kt
package org.example.project
fun simpleFunction(thing: Int): Int {}
现在可以通过像这样导入其他文件来使用它:
OtherFile.kt
import org.example.project.simpleFunction
// simpleFunction can now be used in this file
毫无疑问,正确答案应该是:CarDeclarations.kt
,正如上面 Tenfour04 所说。
作为 Kotlin 的新手,我不确定像下面这样的文件的正确名称是什么:
package de.company.carbase
import de.company.carbase.model.Car
typealias CarSupplier = () -> Car
我把它命名为cars-utils.kt
。仅使用小写字母并有意使用连字符将其与常规 class 文件区分开来。
这对我来说似乎没问题,但也许我错过了一个既定的约定?
文件的 Kotlin 命名约定与 class、对象、接口、枚举等相同
HelperUtil.kt
package org.example.project
fun simpleFunction(thing: Int): Int {}
现在可以通过像这样导入其他文件来使用它:
OtherFile.kt
import org.example.project.simpleFunction
// simpleFunction can now be used in this file
毫无疑问,正确答案应该是:CarDeclarations.kt
,正如上面 Tenfour04 所说。