How do i fix 'type mismatch: inferred type is x but y was expected' in kotlin?

This error occurs when you're trying to assign a variable of one type to another incompatible type.


val number: Int = "123"


val number: Int = "123".toInt()
Ensure that types are compatible or provide the necessary conversions.

Beginner's Guide to Kotlin