Hi,
What is Signleton? Top-level declaration? Module? (In Kotlin)
Hold on now! I know its a very basic question but i’m at the end of a very poor Kotlin course and I want to finish it then follow another course with a better instructor from A-Z Again.
Please don’t compare them with java because I don’t know anything about java.
Thank you.
A singleton is a class from which only a single instance can be created. In Kotlin singletons are defined using the ‘object’ keyword rather than ‘class’.
A top level declaration is a function or property which is defined outside any class, object, interface or other structure.
A module is a set of Kotlin files which are compiled together as a single project.
2 Likes
Normally, when you have a class you can create as many instances of it as you like. However, in the case of a singleton, only one instance is possible. Kotlin uses the ‘object’ keyword to signify a singleton.
A class or object can contain several member functions or properties. In the case of a top level function or property they just stand on their own - they don’t belong to a particular class or object.
1 Like
Btw I moved this from #native to #support . The #native category is used for discussions/questions about Kotlin Native, which is a version of Kotlin not compiling to JVM bytecode (java) but instead directly to machine code.
I guess most of your questions being new should either be in the #support or the #language-design category here
No problem
will do that next time