Issue
Just started using Kotlin and created some activities as Kotlin Files. They work, but still, I want to know what the difference between creating a File and a Class.
Solution
Kotlin Class: Android Studio displays it with no extension if the file contains ONLY ONE class.
Unlike Java, Kotlin allows you to put certain things outside the class like:
- extension functions
- constants
If you, therefore, add any of the above or another class to the file, Android Studio will change it to "Kotlin File":
Removing the above extras, will again show the file as "Kotlin Class"
Answered By - Maciej Beimcik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.