Beginner Kotlin
Q35 / 100

How does Kotlin smart cast work?

Correct! Well done.

Incorrect.

The correct answer is B) After an is type check, the compiler automatically treats the variable as the checked type within the conditional scope

B

Correct Answer

After an is type check, the compiler automatically treats the variable as the checked type within the conditional scope

Explanation

After if (x is String) { ... }, x is automatically treated as String inside the block — no explicit cast needed.

Progress
35/100