package test
fun something() : String? = null
fun main(args : Array<String>) : Unit {
var line : String?
do {
line = something()
if (line != null) {
val x : String = line
} else {
break
}
} while(true);
}
At this code compiler fails with message that x can’t be assigned from line because it String?. Why?
But if I move declaration line like this
``
package test
fun something() : String? = null
fun main(args : Array<String>) : Unit {
do {
val line: String? = something()
if (line != null) {
val x : String = line
} else {
break
}
} while(true);
}
then everything will be OK…
Whether it’s bug or I missed something?