刚开始使用 Kotlin 并创建了一些事件作为 Kotlin 文件。它们可以工作,但我仍然想知道创建文件和创建类之间的区别。
最佳答案
唯一的区别是创建文件会创建一个没有类的文件,而创建一个类会创建一个有一个类的文件。然后,您可以向文件中添加更多类、删除类或进行任何其他更改 - 最终结果不取决于文件的创建方式。
https://stackoverflow.com/questions/42769873/
相关文章:
android - 这种类型有一个构造函数,必须在这里初始化 - Kotlin
android - Android 中的 AsyncTask 与 Kotlin
android - 如何在 kotlin 中使用 Android Support typedef 注
properties - Kotlin 中是否有 didSet/willSet 模拟?
android - kotlin 和 ArgumentCaptor - IllegalStateEx
android - Unresolved reference DaggerApplicationCo