Kotlin Tutorial #19: Flow — Reactive Streams in Kotlin

In the previous tutorial, you learned about advanced coroutine topics. Now let’s learn about Flow. Flow is Kotlin’s way of working with reactive streams. It lets you emit multiple values over time, with full support for coroutines. In this tutorial, you will learn: What is Flow Flow builder and emit/collect Operators: map, filter, take, transform Terminal operators: toList, first, reduce, fold flowOn for changing dispatchers combine and zip Error handling with catch and retry onCompletion and onEach conflate and distinctUntilChanged flatMapConcat, flatMapMerge, flatMapLatest StateFlow and SharedFlow (hot flows) stateIn and shareIn Practical examples What is Flow? Flow is a cold, asynchronous stream that emits values one at a time. ...

March 22, 2026 · 12 min

Kotlin Tutorial #18: Coroutines Deep Dive — Error Handling, SupervisorJob, and Channels

In the previous tutorial, you learned the basics of coroutines: suspend functions, launch, async, and structured concurrency. Now let’s dive deeper into error handling, supervisor jobs, and channels. In this tutorial, you will learn: CoroutineExceptionHandler SupervisorJob and supervisorScope Channels (send, receive, close) Channel types (buffered, conflated, unlimited) produce and consumeEach Fan-out and fan-in patterns select expression Mutex for shared mutable state withTimeout and withTimeoutOrNull Practical patterns Error Handling in Coroutines Error handling in coroutines is different from regular code. When a coroutine throws an exception, the behavior depends on whether you use launch or async. ...

March 22, 2026 · 10 min

Jetpack Compose Tutorial #9: ViewModel — Managing Screen Logic

In Tutorial #5, we learned about remember and mutableStateOf. They work great for simple state. But they have a big problem — when your app needs to load data from a database or API, where does that logic go? Not in the Composable. Composables are for UI, not business logic. That is what ViewModel is for. What is ViewModel? ViewModel is a class that holds your screen’s data and logic. It survives things that destroy and recreate your Composable — like screen rotation or system theme changes. ...

March 22, 2026 · 8 min

Kotlin Tutorial #16: Sequences — Lazy Collections for Performance

In the previous tutorial, you learned about delegation. Now let’s learn about sequences. Sequences are lazy collections that process elements one at a time instead of all at once. This can make a big difference in performance when working with large data sets. In this tutorial, you will learn: Sequences vs Lists (lazy vs eager) Creating sequences generateSequence Sequence builders with yield and yieldAll Infinite sequences When to use sequences Performance comparison Practical examples Sequences vs Lists Lists are eager — they process all elements at each step and create intermediate collections. Sequences are lazy — they process one element through all steps before moving to the next. ...

March 22, 2026 · 9 min

Kotlin Tutorial #15: Delegation — by lazy, Delegates, and Custom Delegation

In the previous tutorial, you learned about error handling. Now let’s learn about delegation. Delegation is a design pattern where an object hands off work to another object. Kotlin has built-in support for delegation using the by keyword. In this tutorial, you will learn: by lazy — lazy initialization Delegates.observable — react to changes Delegates.vetoable — reject invalid changes Map delegation — properties from a map Custom delegates — build your own Class delegation — delegate interface implementation by lazy by lazy creates a property that is computed only once, the first time you access it. After that, the cached value is returned. This is useful for expensive initialization. ...

March 22, 2026 · 8 min

Kotlin Tutorial #14: Error Handling — try/catch, Result, and Patterns

In the previous tutorial, you learned about interfaces and generics. Now let’s learn about error handling. Every program needs to handle errors. Kotlin gives you several tools for this, from traditional try/catch to the modern Result type. In this tutorial, you will learn: try/catch/finally try as an expression Custom exceptions The Result type (runCatching, getOrElse, map, fold) Sealed classes for errors Error handling patterns and best practices try/catch/finally The try/catch block catches exceptions. finally always runs, even after an exception. ...

March 22, 2026 · 8 min

Kotlin Tutorial #13: Interfaces, Generics, and Type Constraints

In the previous tutorial, you learned about sealed classes, enum classes, and value classes. Now let’s learn about interfaces, generics, and type constraints. These features let you write flexible, reusable code while keeping type safety. In this tutorial, you will learn: Interfaces and multiple inheritance Generics with <T> Type constraints with where Variance — in and out Star projection * Reified type parameters Interfaces An interface defines a contract. Classes that implement the interface must provide the required functions and properties. ...

March 22, 2026 · 8 min

Kotlin Tutorial #12: Sealed Classes, Enum Classes, and Value Classes

In the previous tutorial, you learned about scope functions. Now let’s learn about three important types in Kotlin: enum classes, sealed classes, and value classes. Each one solves a different problem, and knowing when to use which will make your code better. In this tutorial, you will learn: Enum classes — fixed set of constants Sealed classes — restricted hierarchies with different data Sealed interfaces — multiple inheritance with sealed types Value classes — type safety without runtime overhead When to use which Enum Classes An enum class defines a fixed set of constants. Every value is known at compile time. ...

March 22, 2026 · 9 min

Kotlin Tutorial #10: Extension Functions and Properties

In the previous tutorial, you learned about lambdas and higher-order functions. Now let’s learn about extension functions and properties. Extensions let you add new functions and properties to existing classes without modifying them. This is one of Kotlin’s best features. You can add a toSlug() function to String or a secondOrNull() function to List — without changing the original class. In this tutorial, you will learn: Extension functions Practical extensions like String.toSlug() and List.secondOrNull() Extension properties Extensions on nullable types Companion object extensions Generic extensions Extension Functions An extension function adds a new function to an existing class. The class you extend is called the “receiver.” ...

March 22, 2026 · 8 min

Kotlin Tutorial #9: Lambdas and Higher-Order Functions

In the previous tutorial, you learned about collections. Now let’s learn about lambdas and higher-order functions. These are some of the most powerful features in Kotlin. A lambda is a function without a name. You already used lambdas with filter, map, and other collection functions. In this tutorial, you will learn how they work in depth. In this tutorial, you will learn: Lambda syntax and the it keyword Trailing lambdas Function types like (Int) -> String Higher-order functions (functions that take or return functions) Function references Closures Inline functions Lambda Syntax A lambda is written between curly braces { }. The arrow -> separates the parameters from the body. ...

March 22, 2026 · 9 min