Intermediate Kotlin
Q57 / 100

How does Kotlin's type inference work?

Correct! Well done.

Incorrect.

The correct answer is B) The compiler deduces the type from the assigned value or return type, so explicit type annotations are often optional

B

Correct Answer

The compiler deduces the type from the assigned value or return type, so explicit type annotations are often optional

Explanation

val x = 42 infers Int. val list = listOf("a") infers List<String>. The compiler analyzes the expression to determine the type.

Progress
57/100