coderef

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.

  • Main function
  • Read-only / mutable
  • String template
  • Convert

Null safety

Handling missing values.

  • Nullable type
  • Safe call / Elvis
  • Smart cast
  • Let

Collections

Lists, maps and sets.

  • Lists
  • Transform
  • Sort
  • Reverse
  • Find / group
  • Map
  • Loop

Control flow & functions

Logic and reuse.

  • If as expression
  • When
  • Function
  • Lambda
  • Extension function

Classes & coroutines

Types and async code.

  • Data class
  • Class with init
  • Inheritance
  • Sealed class
  • Object (singleton)
  • Coroutine
  • Try / catch

← All quick references