Kotlin Quick Reference
Kotlin essentials: val/var, null safety, strings, collections, control flow, functions, data classes and coroutines.
5 sections · 27 snippets · updated Oct 14, 2026
Click any snippet to copy it.
Basics
Variables and output.
TaskCode
- Main function
- Read-only / mutable
- String template
- Convert
Null safety
Handling missing values.
TaskCode
- Nullable type
- Safe call / Elvis
- Smart cast
- Let
Collections
Lists, maps and sets.
TaskCode
- Lists
- Transform
- Sort
- Reverse
- Find / group
- Map
- Loop
Control flow & functions
Logic and reuse.
TaskCode
- If as expression
- When
- Function
- Lambda
- Extension function
Classes & coroutines
Types and async code.
TaskCode
- Data class
- Class with init
- Inheritance
- Sealed class
- Object (singleton)
- Coroutine
- Try / catch