Mark Heckler
02/05/2018, 1:35 PMval someProperty = if (id.isNullOrEmpty())
"Something"
else
padSomeProperty(id)
Note: id is a String? and fun padSomeProperty( sp: String ) parameter is not nullable. But the assignment snippet above results in this compile error:
Error:(16, 32) Kotlin: Type mismatch: inferred type is String? but String was expected
Replacing if (id.isNullOrEmpty()) with if (id == null) works, but isNullOrEmpty() is the better call due to checking for zero-length as well if not null, but short-circuiting if it IS null. So...
...why do I have to change the call to this: padSomeProperty(id!!) ? Thanks in advance for any help. simple smile