Kotlin Glossary
Simple definitions for 48 Kotlin terms.
A
asyncCoroutine builder that returns Deferred<T> for a result you await later.
val d = async { compute() }C
coroutineA lightweight concurrent task that can suspend and resume without blocking a thread.
launch { delay(1000); println("done") }companion objectA singleton object scoped to a class, similar to Java static members.
class Config { companion object { val BASE_URL = "https://api.example.com" } }commentText ignored by the compiler, used to explain code. Line comments use //, block comments use /* */.
// This is a comment
D
data classA class that automatically generates toString, equals, hashCode, and copy.
data class User(val name: String, val age: Int)
DispatcherControls which thread a coroutine runs on. Common values: Main, IO, Default.
withContext(Dispatchers.IO) { readFile() }destructuringUnpacking a data class or Pair into individual variables in one statement.
val (name, age) = user
E
extension functionA function added to an existing type without modifying its class definition.
fun String.shout() = uppercase() + "!"
Elvis operatorThe ?: operator that returns the right side if the left side is null.
val len = name?.length ?: 0
enum classA type representing a fixed set of named constants.
enum class Role { USER, ADMIN }F
funThe keyword used to declare a function in Kotlin.
fun greet() { println("Hi") }FlowA cold asynchronous data stream that emits values sequentially and can be collected.
flow { emit(1); emit(2) }.collect { println(it) }G
genericsType parameters that let you write code working with any type while preserving type safety.
class Box<T>(val value: T)
H
higher-order functionA function that accepts another function as a parameter or returns a function.
fun apply(x: Int, f: (Int) -> Int) = f(x)
I
interfaceA contract that defines functions a class must implement. Kotlin interfaces can have default implementations.
interface Drawable { fun draw() }inheritanceOne class extending another class to reuse and extend its behaviour.
open class Animal class Dog : Animal()
init blockA block of code inside a class that runs when an instance is created.
class Foo { init { println("Created") } }inline functionA function whose body is copied to the call site at compile time, removing call overhead.
inline fun measure(block: () -> Unit) { ... }L
lambdaAn anonymous function that can be passed as a value. Written with curly braces.
val double = { x: Int -> x * 2 }lazyA delegate that initialises a property only the first time it is accessed.
val result: String by lazy { compute() }launchCoroutine builder that starts fire-and-forget work and returns a Job.
launch { fetchData() }M
mutableListOfCreates a modifiable List you can add to and remove from.
val items = mutableListOf("a", "b")MutableStateFlowA hot Flow that holds a current value and emits updates to collectors — common for UI state.
val state = MutableStateFlow(0)
N
nullable typeA type that can hold either a value or null. Denoted with a ? suffix, e.g. String?.
var name: String? = null
non-nullable typeA type that cannot hold null. Kotlin enforces this at compile time.
val name: String = "Kotlin" // cannot be null
O
object keywordDeclares a singleton — a class with exactly one instance, created lazily.
object Logger { fun log(msg: String) = println(msg) }overrideReplaces a parent class or interface function with a new implementation in a subclass.
override fun draw() { println("custom") }openAllows a class or function to be extended or overridden. Kotlin classes are final by default.
open class Base
P
printlnPrints text to the console followed by a newline character.
println("Hello, Kotlin")playgroundAn online browser editor at play.kotlinlang.org for running Kotlin without installing anything.
// Paste code at play.kotlinlang.org
program structureHow a Kotlin file is organised — package, imports, top-level functions, and classes.
fun main() { } // entry pointR
reifiedUsed with inline functions to access the actual type parameter at runtime.
inline fun <reified T> isType(value: Any) = value is T
rangeA sequence of values between a start and end, created with .. or until.
for (i in 1..5) { println(i) }readlnReads one line of text from the console as a non-null String.
val name = readln()
S
sealed classA class whose subclasses are restricted to the same package. Enables exhaustive when expressions.
sealed class Result data class Success(val data: String) : Result()
suspendA modifier that marks a function as suspendable — it can be paused without blocking a thread.
suspend fun loadData(): String { delay(500); return "data" }scope functionA higher-order function (let, run, with, apply, also) that executes a block on an object.
person.apply { age = 26 }smart castAfter a type check, Kotlin automatically casts the value to that type inside the checked block.
if (value is String) { println(value.length) }safe callThe ?. 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
StateFlowA hot Flow that always holds a current value and replays it to new collectors.
val state = MutableStateFlow(0)
SetA collection that holds unique elements with no guaranteed order.
val tags = setOf("kotlin", "android")SharedFlowA hot Flow for broadcasting events to multiple collectors with configurable replay.
val events = MutableSharedFlow<Unit>()
structured concurrencyChild coroutines are tied to a parent scope — cancelling the parent cancels children.
coroutineScope { launch { } }T
type inferenceThe compiler automatically determines a variable's type from its assigned value.
val x = 42 // inferred as Int
try/catchHandles exceptions — try runs risky code, catch handles specific error types.
try { risky() } catch (e: Exception) { println(e) }V
valA read-only variable that cannot be reassigned after its first assignment.
val name = "Kotlin"
varA mutable variable whose value can be changed after declaration.
var count = 0 count = 1
W
whenKotlin's expression for multi-branch logic — replaces switch with more powerful matching.
when (x) { 1 -> "one"; else -> "other" }