fun foo(p: List): Int { val v = p[0] // now check if v is null if (v == null/* null */) return -1 // return -1 return v.length }