Reference materials to support Kotlin learning. We have gathered supplementary resources you may need during the learning process, including a glossary, version comparison, FAQ, and reference links.

Appendix Index#

The table below lists the documents provided in the appendix. Each document is useful for reference during learning or when you need quick information on a specific topic.

DocumentDescription
GlossaryDefinitions of core Kotlin terms
Version ComparisonSummary of major changes from Kotlin 1.x to 2.x
FAQFrequently asked questions and answers
ReferencesOfficial docs, books, and course links

Quick Reference#

A collection of commands and code patterns frequently used in everyday Kotlin development.

Frequently Used Gradle Commands

Gradle Kotlin DSL is the standard build tool for Kotlin projects.

CommandDescription
./gradlew runRun the application
./gradlew buildCompile + test + package
./gradlew testRun tests
./gradlew cleanDelete build artifacts
./gradlew bootRunRun the Spring Boot application
./gradlew run --continuousAuto-run on file changes
./gradlew dependenciesPrint the dependency tree

Null Safety Operators

Kotlin’s core safety mechanisms — the null-related operators.

val nullable: String? = maybeNull()

// Safe call
val length = nullable?.length            // returns null if null

// Elvis operator
val safeLength = nullable?.length ?: 0   // default value if null

// Non-null assertion (avoid when possible)
val forced = nullable!!.length           // throws NullPointerException if null

// Safe cast
val asInt = (any as? Int) ?: -1

Scope Functions — Quick Comparison

FunctionContext ObjectReturn ValueMain Use
letitLambda resultNullable handling, transformation
runthisLambda resultObject configuration + result computation
withthisLambda resultMultiple calls on a non-null object
applythisThe object itselfObject initialization
alsoitThe object itselfSide effects (logging, etc.)

Key Collection Operations

The core operations of Kotlin collections. You can transform, filter, and aggregate data in a functional style.

val nums = listOf(1, 2, 3, 4, 5)

nums.map { it * 2 }            // [2, 4, 6, 8, 10]
nums.filter { it % 2 == 0 }    // [2, 4]
nums.reduce { acc, n -> acc + n }   // 15
nums.fold(0) { acc, n -> acc + n }  // 15
nums.find { it > 3 }           // 4
nums.any { it > 3 }            // true
nums.all { it > 0 }            // true
nums.take(2)                   // [1, 2]
nums.drop(2)                   // [3, 4, 5]
nums.chunked(2)                // [[1, 2], [3, 4], [5]]
nums.groupBy { it % 2 }        // {1=[1, 3, 5], 0=[2, 4]}

Coroutine Builders — Quick Reference

import kotlinx.coroutines.*

// runBlocking - blocks the main thread to run a coroutine (tests, main function)
runBlocking {
    delay(1000)
    println("done")
}

// launch - asynchronous task that does not need a result (returns Job)
val job = CoroutineScope(Dispatchers.IO).launch {
    doWork()
}

// async - asynchronous task that needs a result (returns Deferred)
val deferred = CoroutineScope(Dispatchers.IO).async {
    fetchValue()
}
val result = deferred.await()