Skip to main content

One post tagged with "Type Checks"

The 'Type Checks' tag page includes a variety of articles and tutorials that delve into the concept of type checking in programming. It covers different languages and their unique approaches.

View All Tags

Exploring Kotlin's Smart Casts

· 7 min read
Engineering Team

In this tutorial, we will explore the concept of smart casts in Kotlin. Smart casts allow us to automatically cast a variable to a more specific type based on certain conditions. This can greatly simplify our code and make it more readable and concise. We will cover the basics of smart casts, how to use them with type checks, the safe cast operator, using 'is' and '!' operators, smart casts in when expressions, limitations of smart casts, and finally, some tips on avoiding smart cast errors.

Practical product notes

Get the next useful guide

Occasional tutorials, product resources, and lessons from building and launching software.