<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8" -->

---
title: Type Casting and Smart Cast in Kotlin: A Complete Guide...
description: A beginner-friendly guide to type casting in Kotlin covering the `is` operator, smart casts, unsafe casting with `as`, and safe casting with `as?`. Explains...
canonical: https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Type Casting and Smart Cast in Kotlin: A Complete Guide for Beginners | daily.dev
og:description: A beginner-friendly guide to type casting in Kotlin covering the `is` operator, smart casts, unsafe casting with `as`, and safe casting with `as?`. Explains...
og:url: https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8
og:image: https://api.daily.dev/og/posts/jbCUwVeW8.png
og:image:alt: Type Casting and Smart Cast in Kotlin: A Complete Guide for Beginners
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Type Casting and Smart Cast in Kotlin: A Complete Guide for Beginners

**[Medium](https://daily.dev/sources/medium_js)** · 6 min read · 0 upvotes · 0 comments

## Summary

A beginner-friendly guide to type casting in Kotlin covering the `is` operator, smart casts, unsafe casting with `as`, and safe casting with `as?`. Explains how Kotlin's smart cast feature automatically converts objects to the correct type after a type check, reducing boilerplate compared to Java. Includes practical Android examples such as RecyclerView with multiple view types and API response handling with sealed classes, plus best practices and a practice exercise.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://techdynasty.medium.com/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-992f8c45dd70>

## Similar posts on daily.dev

- [Variables, Constants, and Data Types in Kotlin: A Beginner-Friendly Guide](https://daily.dev/posts/variables-constants-and-data-types-in-kotlin-a-beginner-friendly-guide-rkyab6sww) · Medium · 0 upvotes · 0 comments
- [Learn Modern Kotlin](https://daily.dev/posts/learn-modern-kotlin-emjhfvz0q) · freeCodeCamp · 1 upvotes · 0 comments
- [Evaluating Kotlin in Real Projects](https://daily.dev/posts/evaluating-kotlin-in-real-projects-4hvtaptzn) · JetBrains · 4 upvotes · 0 comments

---

Tags: [#android](https://daily.dev/tags/android), [#kotlin](https://daily.dev/tags/kotlin)

[View this post on daily.dev](https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Type Casting and Smart Cast in Kotlin: A Complete Guide for Beginners","url":"https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8"},"datePublished":"2026-07-22T17:37:57.997Z","dateModified":"2026-07-22T17:38:48.979Z","description":"A beginner-friendly guide to type casting in Kotlin covering the `is` operator, smart casts, unsafe casting with `as`, and safe casting with `as?`. Explains...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2db4246fed5fa7fe9b858da8a33a7bdc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2db4246fed5fa7fe9b858da8a33a7bdc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/type-casting-and-smart-cast-in-kotlin-a-complete-guide-for-beginners-jbcuwvew8","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"android,kotlin","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Type Casting and Smart Cast in Kotlin: A Complete Guide for Beginners"}]}
```

