Skip to main content
InterviewHubPRO
Section Overview
Q8

Question 8 of 50

Part 1: Core Language, Type System & Syntax (1 - 10)

16%
Kotlin & Coroutines (50 Qs)•Part 1: Core Language, Type System & Syntax (1 - 10)

What is Smart Casting in Kotlin and when does the compiler fail to smart cast?

senior LevelkotlinCore Language

In Simple Words: After an is type check or != null check, Kotlin automatically casts the variable. It fails if the variable is a mutable var accessible by other threads or custom getters.