Which line of code is a shorter, more idiomatic version of the displayed snippet?
val len: Int = if (x != null) x.length else -1
val len: Int = if (x != null) x.length else -1A. val len = x?.let{x.len} else {-1}
B. val len = x!!.length ?: -1
C. val len:Int = (x != null)? x.length : -1
D. val len = x?.length ?: -1
Answer: Option D
Related Questions on Kotlin Program
A. A new version of Java.
B. A JavaScript framework.
C. A statically-typed programming language for the JVM, Android, and browser.
D. A database management system.
Which platform does Kotlin primarily target?
A. Python Bytecode
B. JavaScript
C. JVM (Java Virtual Machine) Bytecode
D. PHP

Join The Discussion