`kotlinx-datetime` is the multiplatform date/time library — works on JVM, JS, Native. `Instant` (UTC moment), `LocalDate`, `TimeZone` are the building blocks.
JUnit 5 + Kotlin: `@ParameterizedTest` runs the same test body with multiple input rows. `@CsvSource` for inline data, `@MethodSource` for complex args.
Kotlin Ktor Server — JSON API with kotlinx.serialization
Install `ContentNegotiation` + `Json` plugin and you get typed (de)serialization for every route. Decode request bodies into data classes; respond with data classes.
`out T` (covariant) → producer of T; can be assigned to a wider type. `in T` (contravariant) → consumer of T; can be assigned to a narrower type. Without modifiers, generics are invariant (strict match).
In an `inline` function, a `reified` type parameter survives erasure — you can use `T::class`, `is T`, `as T` at runtime. The killer use-case for JSON parsers ("give me a List<User>").
`<T>` declares a type parameter. Use it on classes (`Box<T>`) and functions (`fun <T> identity(x: T) = x`). Type bounds (`T : Comparable<T>`) constrain what T can be.
`withTimeout(ms) { ... }` cancels the inner coroutine if it doesn't finish in time and throws `TimeoutCancellationException`. `withTimeoutOrNull` returns null instead.
A `List` materializes every intermediate `map`/`filter` result. A `Sequence` processes ONE element through the whole pipeline at a time — better for big inputs or short-circuiting (`first`, `take`).
`groupBy` returns a `Map<Key, List<T>>` keyed by what the lambda returns. `partition` is a special-case `groupBy` for booleans — returns `(matching, nonMatching)` Pair.
`listOf` / `setOf` / `mapOf` build READ-ONLY views; `mutableListOf` / `mutableSetOf` / `mutableMapOf` are mutable. Default to immutable — the call site is a contract about intent.
`object` declares a thread-safe lazy singleton. Built into the language — no `private constructor + getInstance()` boilerplate. Also: anonymous `object : Interface { … }` for one-shot instances.
`?.` is the safe-call operator — short-circuits to `null` at the first null in a chain. Pair with `?:` (Elvis) for "this or a default". Replaces nested if-not-null ladders.
Kotlin Nullable Types — String? and the ? Operator
Kotlin distinguishes `String` (never null) from `String?` (may be null) in the type system. The compiler refuses to compile code that could deref a possibly-null value — the famous "no more NullPointerException" feature.