Basics of Kotlin
suggest changeThis topic covers the basics of Kotlin for beginners.
Remarks
- A Kotlin file has the extension
.kt. - All classes in Kotlin have a common superclass
Any, the default super for a class with no supertypes declared (similar toObjectin Java). - Variables can be declared as
val(immutable — assign once) orvar(mutable — the value can be changed). - A semicolon is not needed at the end of a statement.
- If a function does not return any useful value, its return type is
Unit. DeclaringUnitis optional. - Referential equality is checked by the
===operator.a === bevaluates totrueif and only ifaandbpoint to the same object.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents