Kotlin Glossary

Simple definitions for 48 Kotlin terms.

A

async

Coroutine builder that returns Deferred<T> for a result you await later.

val d = async { compute() }
Tutorial →

C

coroutine

A lightweight concurrent task that can suspend and resume without blocking a thread.

launch { delay(1000); println("done") }
Tutorial →
companion object

A singleton object scoped to a class, similar to Java static members.

class Config { companion object { val BASE_URL = "https://api.example.com" } }
Tutorial →
comment

Text ignored by the compiler, used to explain code. Line comments use //, block comments use /* */.

// This is a comment
Tutorial →

D

data class

A class that automatically generates toString, equals, hashCode, and copy.

data class User(val name: String, val age: Int)
Tutorial →
Dispatcher

Controls which thread a coroutine runs on. Common values: Main, IO, Default.

withContext(Dispatchers.IO) { readFile() }
Tutorial →
destructuring

Unpacking a data class or Pair into individual variables in one statement.

val (name, age) = user
Tutorial →

E

extension function

A function added to an existing type without modifying its class definition.

fun String.shout() = uppercase() + "!"
Tutorial →
Elvis operator

The ?: operator that returns the right side if the left side is null.

val len = name?.length ?: 0
Tutorial →
enum class

A type representing a fixed set of named constants.

enum class Role { USER, ADMIN }
Tutorial →

F

fun

The keyword used to declare a function in Kotlin.

fun greet() { println("Hi") }
Tutorial →
Flow

A cold asynchronous data stream that emits values sequentially and can be collected.

flow { emit(1); emit(2) }.collect { println(it) }
Tutorial →

G

generics

Type parameters that let you write code working with any type while preserving type safety.

class Box<T>(val value: T)
Tutorial →

H

higher-order function

A function that accepts another function as a parameter or returns a function.

fun apply(x: Int, f: (Int) -> Int) = f(x)
Tutorial →

I

interface

A contract that defines functions a class must implement. Kotlin interfaces can have default implementations.

interface Drawable { fun draw() }
Tutorial →
inheritance

One class extending another class to reuse and extend its behaviour.

open class Animal
class Dog : Animal()
Tutorial →
init block

A block of code inside a class that runs when an instance is created.

class Foo { init { println("Created") } }
Tutorial →
inline function

A function whose body is copied to the call site at compile time, removing call overhead.

inline fun measure(block: () -> Unit) { ... }
Tutorial →

L

lambda

An anonymous function that can be passed as a value. Written with curly braces.

val double = { x: Int -> x * 2 }
Tutorial →
lazy

A delegate that initialises a property only the first time it is accessed.

val result: String by lazy { compute() }
Tutorial →
launch

Coroutine builder that starts fire-and-forget work and returns a Job.

launch { fetchData() }
Tutorial →

M

mutableListOf

Creates a modifiable List you can add to and remove from.

val items = mutableListOf("a", "b")
Tutorial →
MutableStateFlow

A hot Flow that holds a current value and emits updates to collectors — common for UI state.

val state = MutableStateFlow(0)
Tutorial →

N

nullable type

A type that can hold either a value or null. Denoted with a ? suffix, e.g. String?.

var name: String? = null
Tutorial →
non-nullable type

A type that cannot hold null. Kotlin enforces this at compile time.

val name: String = "Kotlin" // cannot be null
Tutorial →

O

object keyword

Declares a singleton — a class with exactly one instance, created lazily.

object Logger { fun log(msg: String) = println(msg) }
Tutorial →
override

Replaces a parent class or interface function with a new implementation in a subclass.

override fun draw() { println("custom") }
Tutorial →
open

Allows a class or function to be extended or overridden. Kotlin classes are final by default.

open class Base
Tutorial →

P

println

Prints text to the console followed by a newline character.

println("Hello, Kotlin")
Tutorial →
playground

An online browser editor at play.kotlinlang.org for running Kotlin without installing anything.

// Paste code at play.kotlinlang.org
Tutorial →
program structure

How a Kotlin file is organised — package, imports, top-level functions, and classes.

fun main() { } // entry point
Tutorial →

R

reified

Used with inline functions to access the actual type parameter at runtime.

inline fun <reified T> isType(value: Any) = value is T
Tutorial →
range

A sequence of values between a start and end, created with .. or until.

for (i in 1..5) { println(i) }
Tutorial →
readln

Reads one line of text from the console as a non-null String.

val name = readln()
Tutorial →

S

sealed class

A class whose subclasses are restricted to the same package. Enables exhaustive when expressions.

sealed class Result
data class Success(val data: String) : Result()
Tutorial →
suspend

A modifier that marks a function as suspendable — it can be paused without blocking a thread.

suspend fun loadData(): String { delay(500); return "data" }
Tutorial →
scope function

A higher-order function (let, run, with, apply, also) that executes a block on an object.

person.apply { age = 26 }
Tutorial →
smart cast

After a type check, Kotlin automatically casts the value to that type inside the checked block.

if (value is String) { println(value.length) }
Tutorial →
safe call

The ?. operator that calls a method or accesses a property only if the receiver is not null.

val len = name?.length // null if name is null
Tutorial →
StateFlow

A hot Flow that always holds a current value and replays it to new collectors.

val state = MutableStateFlow(0)
Tutorial →
Set

A collection that holds unique elements with no guaranteed order.

val tags = setOf("kotlin", "android")
Tutorial →
SharedFlow

A hot Flow for broadcasting events to multiple collectors with configurable replay.

val events = MutableSharedFlow<Unit>()
Tutorial →
structured concurrency

Child coroutines are tied to a parent scope — cancelling the parent cancels children.

coroutineScope { launch { } }
Tutorial →

T

type inference

The compiler automatically determines a variable's type from its assigned value.

val x = 42 // inferred as Int
Tutorial →
try/catch

Handles exceptions — try runs risky code, catch handles specific error types.

try { risky() } catch (e: Exception) { println(e) }
Tutorial →

V

val

A read-only variable that cannot be reassigned after its first assignment.

val name = "Kotlin"
Tutorial →
var

A mutable variable whose value can be changed after declaration.

var count = 0
count = 1
Tutorial →

W

when

Kotlin's expression for multi-branch logic — replaces switch with more powerful matching.

when (x) { 1 -> "one"; else -> "other" }
Tutorial →