170 cards
Kotlin's type system starts with two declarations that differ only in mutability: val creates a read-only reference that cannot be reassigned, while var creates a mutable one. Beyond this, the basic types are numbers (Int, Long, Short, Byte, Float, Double), Boolean, Char, and String — every Kotlin type is an object at...
Null safety is Kotlin's most celebrated feature, designed to eliminate NullPointerException at compile time. By default, types are non-nullable — declaring var name: String means the compiler will reject any attempt to assign null. To permit it, you append a question mark to declare a nullable type, as in String?. Once...
Kotlin classes are final by default, meaning they cannot be inherited unless explicitly marked open. An open class can be extended, and its members can be overridden with the override keyword — which is itself open unless combined with final, allowing subclasses to further override. Abstract classes go further, forbidd...
Functions are first-class citizens in Kotlin. A higher-order function is one that takes a function as a parameter or returns one, opening up powerful composition patterns. The function-typed parameters are typically supplied as lambdas — anonymous functions written as literals. With a single parameter, you can use the...
Kotlin's property model unifies simple field access with getter and setter logic. A declaration like val name: String creates a property that the compiler backs with a private field and a synthetic accessor method. You can override these accessors when logic is needed, as in val fullName: String get() = "$first $last"...
Kotlin's collection library distinguishes read-only interfaces from their mutable counterparts. List, Set, and Map describe immutable collections, while MutableList, MutableSet, and MutableMap extend them with mutation methods like add, remove, and clear. The standard factories — listOf(), mutableListOf(), setOf(), mut...
Coroutines are Kotlin's framework for writing asynchronous code that looks synchronous. A coroutine is a lightweight, cooperatively scheduled unit of work that can be paused and resumed at suspension points without blocking the underlying thread — so thousands of coroutines can share a small thread pool efficiently. Fu...