# when expression

Published articles for when expression.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Sealed Types

DevFeed: [Sealed Types](<https://devfeed.tech/articles/sealed-types-25064.md>)

Original publisher: [Read original article](<https://typealias.com/start/kotlin-sealed-types/>)

Author: author@typealias.com (Dave Leeds)

Published: 2024-01-16T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>)

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [enum](<https://devfeed.tech/tags/enum.md>), [exhaustive](<https://devfeed.tech/tags/exhaustive.md>), [exhaustive-matching](<https://devfeed.tech/tags/exhaustive-matching.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [programming](<https://devfeed.tech/tags/programming.md>), [sealed](<https://devfeed.tech/tags/sealed.md>), [sealed-class](<https://devfeed.tech/tags/sealed-class.md>), [sealed-interface](<https://devfeed.tech/tags/sealed-interface.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [types](<https://devfeed.tech/tags/types.md>), [when-conditional](<https://devfeed.tech/tags/when-conditional.md>), [when-expression](<https://devfeed.tech/tags/when-expression.md>)

### AI overview

A tutorial chapter explains how Kotlin sealed interfaces and classes restrict the set of possible types, helping ensure that all possibilities are handled in a when expression.

### Source excerpt

In Chapter 5, we saw how limiting our options can be a good thing. In that chapter, we used enum classes to limit our values, which allows Kotlin to ensure that we account for all possibilities in a when expression. We can get a similar benefit for our types by using sealed interfaces and classes. In this chapter, we'll visit Cecil's Ice Shop to learn all about sealed types. Let's get started!

## Kotlin Conditionals: When and If

DevFeed: [Kotlin Conditionals: When and If](<https://devfeed.tech/articles/kotlin-conditionals-when-and-if-25050.md>)

Original publisher: [Read original article](<https://typealias.com/start/kotlin-conditionals/>)

Author: author@typealias.com (Dave Leeds)

Published: 2020-05-05T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [conditionals](<https://devfeed.tech/tags/conditionals.md>), [if-expression](<https://devfeed.tech/tags/if-expression.md>), [if-statement](<https://devfeed.tech/tags/if-statement.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [programming](<https://devfeed.tech/tags/programming.md>), [when-expression](<https://devfeed.tech/tags/when-expression.md>), [writing-code](<https://devfeed.tech/tags/writing-code.md>)

### AI overview

A beginner-oriented chapter explaining Kotlin conditionals through branches, execution paths, and a Goldilocks porridge temperature example.

### Source excerpt

In real life, we do different things depending on the circumstances. For example, if it's raining outside, you'll probably grab an umbrella. If it's sunny outside, you might grab your sunglasses. We do different things depending on the weather. Similarly, we often need our code to do different things in different situations, so in this chapter, we'll look at Kotlin's conditionals. Goldilocks and the Three Branches You might have heard the fairy tale of Goldilocks and the Three Bears.

## Using the Kotlin when Expression

DevFeed: [Using the Kotlin when Expression](<https://devfeed.tech/articles/using-when-expression-in-kotlin-the-switch-with-super-powers-kad-13-27237.md>)

Original publisher: [Read original article](<https://antonioleiva.com/when-expression-kotlin>)

Published: 2017-02-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [condition](<https://devfeed.tech/tags/condition.md>), [examples](<https://devfeed.tech/tags/examples.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [types](<https://devfeed.tech/tags/types.md>), [when-expression](<https://devfeed.tech/tags/when-expression.md>)

### AI overview

A tutorial on Kotlin's when expression, covering regular use, alternative branches, automatic casting, range and list checks, argument-free conditions, and returning values. It also includes an Android example involving event handling.

### Source excerpt

Everything Android, Kotlin and other random topics

## Converting Plaid to Kotlin: Lessons learned (Part 2)

DevFeed: [Converting Plaid to Kotlin: Lessons learned (Part 2)](<https://devfeed.tech/articles/converting-plaid-to-kotlin-lessons-learned-part-2-27215.md>)

Original publisher: [Read original article](<https://antonioleiva.com/plaid-kotlin-2>)

Published: 2015-11-17T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [callback](<https://devfeed.tech/tags/callback.md>), [code](<https://devfeed.tech/tags/code.md>), [expression](<https://devfeed.tech/tags/expression.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [map](<https://devfeed.tech/tags/map.md>), [maps](<https://devfeed.tech/tags/maps.md>), [when-expression](<https://devfeed.tech/tags/when-expression.md>)

### AI overview

Part 2 of a series about porting the Plaid Android app to Kotlin. It examines how Kotlin can reduce boilerplate and improve readability, including class simplification, when expressions, map operations, and converting Retrofit callbacks into lambdas.

### Source excerpt

Everything Android, Kotlin and other random topics