Skip to main content

2 posts tagged with "Null Safety"

Our Null Safety tag archive features a wide range of articles and tutorials designed to help you understand and implement null safety in your coding practices.

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.