I wrote the next code and it runs well saying me that variable a is an Int. But if I explicitly define it as an Int I get a compile error. What is happening?
fun main(args: Array<String>) {
//writing "val a:Int" doesn't compile
val a = listOf(1, 2, 3, 4, 5).let letLoop@{
it.forEach{ number ->
if (number == 3) {
return@letLoop number
}
}
}
println("${a::class.qualifiedName}")
println(a is Int)
println(a)
}