Question: Which line of code is a shorter, more idiomatic version of the displayed snippet?

  1. `val len = x?.let{x.len} else {-1}`
  2. `val len = x!!.length ?: -1`
  3. `val len:Int = (x != null)? x.length : -1`
  4. `val len = x?.length ?: -1`

Answer: The correct answer of the above question is Option D:`val len = x?.length ?: -1`