# smart cast

Published articles for smart cast.

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

## The problem of union types for type systems

DevFeed: [The problem of union types for type systems](<https://devfeed.tech/articles/the-problem-of-union-types-for-type-systems-39390.md>)

Original publisher: [Read original article](<https://kt.academy/article/union-types-into>)

Published: 2024-06-10T00:00:00Z

Content type: opinion

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [union types](<https://devfeed.tech/topics/union-types.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [subtype](<https://devfeed.tech/topics/subtype.md>), [generics](<https://devfeed.tech/topics/generics.md>)

Tags: [generics](<https://devfeed.tech/tags/generics.md>), [inference](<https://devfeed.tech/tags/inference.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-languages](<https://devfeed.tech/tags/programming-languages.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>), [static](<https://devfeed.tech/tags/static.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [type](<https://devfeed.tech/tags/type.md>), [types](<https://devfeed.tech/tags/types.md>), [union](<https://devfeed.tech/tags/union.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

This article explains why general union types are difficult to add to Kotlin and other statically typed systems. It discusses ambiguity in subtype relationships and generic type inference, including the claim that inference is NP-hard, then describes Kotlin's proposed limited use of union types for representing errors through rich errors.

### Source excerpt

Why union types are not such a good idea for static type systems.

## Introduction to Interfaces

DevFeed: [Introduction to Interfaces](<https://devfeed.tech/articles/introduction-to-interfaces-25058.md>)

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

Author: author@typealias.com (Dave Leeds)

Published: 2022-09-12T00: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: [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [cast](<https://devfeed.tech/tags/cast.md>), [code](<https://devfeed.tech/tags/code.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [language](<https://devfeed.tech/tags/language.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [programming](<https://devfeed.tech/tags/programming.md>), [safe-cast](<https://devfeed.tech/tags/safe-cast.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>), [unsafe-cast](<https://devfeed.tech/tags/unsafe-cast.md>)

### AI overview

This Kotlin tutorial introduces interfaces as a language feature that lets a single object have more than one type. It builds on Kotlin's built-in and custom types and begins illustrating the concept with a chicken and farmer example.

### Source excerpt

Ever since Chapter 1, we've used a variety of built-in Kotlin types, like Int, String, and Boolean. Then in Chapter 4, we introduced our own custom types, like Circle, by writing classes. In this chapter, we'll dive into interfaces, which allow you to declare that a single object has more than one type at a time! Interfaces are a powerful language feature, and when used well, they can take your code to the next level.

## Nulls and Null Safety

DevFeed: [Nulls and Null Safety](<https://devfeed.tech/articles/nulls-and-null-safety-25061.md>)

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

Author: author@typealias.com (Dave Leeds)

Published: 2021-03-30T00: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>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>)

Tags: [elvis-operator](<https://devfeed.tech/tags/elvis-operator.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>), [not-null-assertion-operator](<https://devfeed.tech/tags/not-null-assertion-operator.md>), [null](<https://devfeed.tech/tags/null.md>), [null-safety](<https://devfeed.tech/tags/null-safety.md>), [optional](<https://devfeed.tech/tags/optional.md>), [programming](<https://devfeed.tech/tags/programming.md>), [safe-call-operator](<https://devfeed.tech/tags/safe-call-operator.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>)

### AI overview

An introduction to nulls and null safety in Kotlin, explaining that variables may not always hold a value and setting up a coffee-rating example implemented in Kotlin.

### Source excerpt

So far in this book, every time that we created a variable, whether it was a String, an Int, or a Boolean, we assigned a value to it. There are times, though, when we need to create a variable that might not actually hold a value! This brings us to the exciting topic of nulls! Introduction to Nulls James has set up a coffee stand downtown, and he's ready to start sharing his fine brew!

## Useful Kotlin Features Compared with Java

DevFeed: [Useful Kotlin Features Compared with Java](<https://devfeed.tech/articles/kotlin-useful-but-unfairly-not-mentioned-features-38636.md>)

Original publisher: [Read original article](<https://krossovochkin.com/posts/2020_05_03_kotlin_useful_but_unfairly_not_mentioned_features/>)

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

Content type: tutorial

Language: en

Sources: [Vasya Drobushkov](<https://devfeed.tech/sources/vasya-drobushkov.md>)

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

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [hashcode](<https://devfeed.tech/tags/hashcode.md>), [immutability](<https://devfeed.tech/tags/immutability.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [modifiers](<https://devfeed.tech/tags/modifiers.md>), [package-private](<https://devfeed.tech/tags/package-private.md>), [process](<https://devfeed.tech/tags/process.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>), [visibility](<https://devfeed.tech/tags/visibility.md>)

### AI overview

This article compares Kotlin with Java through several less-discussed language differences. The supplied text covers immutable method-parameter references in Kotlin and contrasts Java visibility modifiers, including protected and package-private access.

### Source excerpt

Source Introduction Many of us first learned Kotlin after Java. Learning process was fairly simple because Kotlin has many similarities when at the same time improves development experience by fighting common pain points Java developer (especially on Java 6, which is common in Android world) has to encounter every day. There are a bunch of articles about cool Kotlin features like immutability, handling nullability, smart-cast, data classes, and so forth. Yes, these features are great. Having to add a bunch of nullability annotations, final keywords, override equals/hashCode methods, create additional local variables after type checks -- all of this adds unnecessary work that needs to be done all the time.

## Top 10 Kotlin Stack Overflow questions, pt 3 - nulls and such

DevFeed: [Top 10 Kotlin Stack Overflow questions, pt 3 - nulls and such](<https://devfeed.tech/articles/top-10-kotlin-stack-overflow-questions-pt-3-nulls-and-such-27091.md>)

Original publisher: [Read original article](<https://zsmb.co/top-10-kotlin-stack-overflow-questions-3/>)

Author: Márton Braun

Published: 2018-05-08T08:00:00Z

Content type: tutorial

Language: en

Sources: [zsmb.co](<https://devfeed.tech/sources/zsmb-co.md>)

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

Tags: [android](<https://devfeed.tech/tags/android.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [marton-braun](<https://devfeed.tech/tags/marton-braun.md>), [null](<https://devfeed.tech/tags/null.md>), [safe-call-operator](<https://devfeed.tech/tags/safe-call-operator.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>), [stack-overflow](<https://devfeed.tech/tags/stack-overflow.md>), [zsmb](<https://devfeed.tech/tags/zsmb.md>), [zsmb-co](<https://devfeed.tech/tags/zsmb-co.md>), [zsmb13](<https://devfeed.tech/tags/zsmb13.md>), [zsmbco](<https://devfeed.tech/tags/zsmbco.md>)

### AI overview

The third and final article in a series explains Kotlin nullability, including why smart casts do not work on mutable properties and how the null assertion operator can cause runtime crashes.

### Source excerpt

The third and final part covers topics of nullability and some small extras to wrap up the series.

## How To Build A Todo List In Kotlin Part 4: Storing Items

DevFeed: [How To Build A Todo List In Kotlin Part 4: Storing Items](<https://devfeed.tech/articles/how-to-build-a-todo-list-in-kotlin-part-4-storing-items-22814.md>)

Original publisher: [Read original article](<http://androidessence.com/how-to-build-a-todo-list-in-kotlin-part-4-storing-items/>)

Author: Adam McNeilly

Published: 2017-05-21T00:00:00Z

Content type: tutorial

Language: en

Sources: [Android Essence](<https://devfeed.tech/sources/android-essence.md>)

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

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [app](<https://devfeed.tech/tags/app.md>), [code](<https://devfeed.tech/tags/code.md>), [data](<https://devfeed.tech/tags/data.md>), [elvis-operator](<https://devfeed.tech/tags/elvis-operator.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [smart-cast](<https://devfeed.tech/tags/smart-cast.md>), [streams](<https://devfeed.tech/tags/streams.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

### AI overview

A Kotlin tutorial explains how to persist items in an Android todo list application by writing tasks to a text file and reading them back. It also discusses updating storage during activity lifecycle events and briefly explains Kotlin streams, smart casts, and the elvis operator.

### Source excerpt

If you've been following along with parts 1-3, you now have an (almost) working todo list application. The only thing we are missing is persisting the data. Running your Android app now and rotating your screen will show you that the items you add won't persist, and disappear anytime an activity is killed and recreated. This post will show you how to write the list to a text file and read from it.