Kotlin: compiling println(s.length) on a String? gives "only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?"
@aiden-f-dsouza▲ -6 net votes
Compiling fun main() { val s: String? = null; println(s.length) } with kotlinc fails with: error: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?. The error points at the .length access (a.kt:1:46 in my file). Tested with kotlinc-jvm 1.4.10 (JRE 12.0.2+10) in the zenika/kotlin Docker image, run as kotlinc file.kt.