Data Types Workbook
Eleven short exercises on Kotlin's basic types — val and var, the number types, explicit conversions, strings and templates, nullability, and Unit and Nothing.
Short coding exercises to practice the concepts from each Kotlin lesson.
Eleven short exercises on Kotlin's basic types — val and var, the number types, explicit conversions, strings and templates, nullability, and Unit and Nothing.
Fifteen short exercises on Kotlin functions — single-expression bodies, default and named arguments, vararg, and top-level and local functions. Solutions reveal on click.
Eleven short exercises on Kotlin control flow — if as an expression, ranges, for loops, membership with in, indices, and labelled break.
Ten short exercises on Kotlin's when — as a statement and an expression, with and without a subject, range and type matching, multiple values per branch, and exhaustiveness.
Ten short exercises on Kotlin smart casts — is and !is, null-check narrowing, smart casts in when, combined conditions, early returns, and where they don't apply.
Ten short exercises on Kotlin null safety — safe calls, the Elvis operator, !!, safe casts, ?.let, lateinit, nullable collections, and platform types.
Eleven short exercises on Kotlin collections — read-only versus mutable, the factory functions, map access, getOrDefault, the plus and minus operators, and read-only signatures.
Twelve short exercises on the lambda basics — defining and calling, parameters and results, function types, the implicit it, and multi-line bodies.
Thirteen short exercises on lambdas at work — forEach, the trailing-lambda convention, map and filter, chaining, the any/all/count/find/sumOf toolkit, and writing your own higher-order function.
Eleven short exercises on closures — capturing parameters, capturing and mutating a var, returning a stateful lambda, shared state, and capturing a loop variable.
Twelve short exercises on the four kinds of function reference, non-local returns and labels, and anonymous functions.
Eleven short exercises on inline functions and lambdas with a receiver — marking a function inline, reified, receiver lambda types, apply and buildString, and writing a receiver-based builder.
Eleven short exercises on Kotlin classes — declarations, primary constructors, properties, init blocks, custom accessors, encapsulation, and inheritance.
Ten short exercises on Kotlin's specialized classes — data classes, enums, sealed hierarchies, objects and companions, inner classes, and value classes.
Ten short exercises on Kotlin enums — constants, exhaustive when, constructor properties, methods, per-constant overrides, the built-in members, and implementing interfaces.
Ten short exercises on Kotlin interfaces — implementing them, default methods, property contracts, resolving clashes between defaults, functional interfaces, and interface inheritance.
Ten short exercises on Kotlin extensions — declaring extension functions and properties, the receiver, static resolution, nullable receivers, and members winning over extensions.
Ten short exercises on Kotlin equality — structural == versus referential ===, null-safe comparison, data-class equals and hashCode, and Comparable with the comparison operators.
Ten short exercises on Kotlin destructuring — declarations, the componentN convention, data classes, map entries, withIndex, lambda parameters, skipping with underscore, and custom components.
Ten short exercises on Kotlin visibility — the default, private and protected, the module-scoped internal, private setters, private constructors, and file organization.
Nine short exercises on Kotlin delegation — class delegation with by, lazy and observable properties, map-backed properties, writing a custom delegate, and lateinit versus lazy.
Nine short exercises on Kotlin generics — generic functions and classes, declaration-site variance with out and in, star projections, and reified type parameters.
Ten short exercises on Kotlin exception handling — try/catch as an expression, require and check, use for resources, runCatching and Result, Nothing, and sealed result types.
Ten short exercises on Kotlin/Java interop — getters as properties, platform types, SAM conversion, and the @Jvm annotations that make Kotlin pleasant to call from Java.
Ten short exercises on Kotlin's scope functions — let, run, with, apply, and also, decided by receiver-versus-parameter and result-versus-object, plus takeIf and takeUnless.
Ten short exercises on Kotlin operator overloading — plus, get and set, invoke, contains, compareTo, compound assignment, unaryMinus, and making a type iterable.
Nine short exercises on Kotlin coroutines — suspend functions, suspension points, launch, async and await, coroutineScope, structured concurrency, and dispatchers.