Catalog / Kotlin Cheatsheet
Kotlin Cheatsheet
A concise reference for Kotlin syntax, keywords, and common patterns, designed to accelerate development and provide quick solutions.
Kotlin Basics
Variables
|
Read-only variable, value assigned once.
|
|
Mutable variable, value can be changed.
|
Type Inference |
Kotlin can often infer variable types.
|
Nullable Types |
Variables can be declared as nullable using
|
Lateinit |
For non-null vars that are initialized later.
|
Constants |
Compile-time constants must be declared at the top level or as members of
|
Functions
Basic Function |
|
Single-Expression Function |
|
Default Arguments |
|
Named Arguments |
|
Varargs |
|
Control Flow
|
|
|
|
Classes and Objects
Classes
Basic Class |
|
Constructors |
Primary and secondary constructors.
|
Data Classes |
Automatically generates
|
Inheritance |
Classes are
|
Abstract Classes |
|
Objects
Object Declaration (Singleton) |
|
Companion Objects |
Like static members in Java.
|
Interfaces
|
Collections and Functional Programming
Collections
|
|
|
|
|
|
|
|
|
|
|
|
Functional Operations
|
|
|
|
|
|
Coroutines
Basic Usage
|
Fire and forget coroutine.
|
|
Coroutine that returns a result using
|
|
Bridge between non-coroutine world and coroutine world.
|
Coroutine Scope
|
Suspending Functions
Marked with
|