Basics of Kotlin

suggest change

This topic covers the basics of Kotlin for beginners.

Remarks

  1. A Kotlin file has the extension .kt.
  2. All classes in Kotlin have a common superclass Any, the default super for a class with no supertypes declared (similar to Object in Java).
  3. Variables can be declared as val (immutable — assign once) or var (mutable — the value can be changed).
  4. A semicolon is not needed at the end of a statement.
  5. If a function does not return any useful value, its return type is Unit. Declaring Unit is optional.
  6. Referential equality is checked by the === operator. a === b evaluates to true if and only if a and b point to the same object.

Basic examples

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents